diff --git a/CHANGELOG.md b/CHANGELOG.md
index 92c8fe99..cad88a41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#473] Added `BuildContext.SetEnableUVDistributionRecalculation` to allow opting out from the automatic call to
`Mesh.RecalculateUVDistributionMetrics` on generated meshes.
- [#478] Added `ProfilerScope` API
+- [#481] Added `NDMFPreview.GetOriginalObjectForProxy`
- [#480] Added `IExtensionContext.Owner` API. Setting this property will allow errors to be correctly attributed to the
plugin that contains an extension context.
- [#479] Added `IAssetSaver` and `SerializationScope` APIs.
diff --git a/Editor/PreviewSystem/NDMFPreview.cs b/Editor/PreviewSystem/NDMFPreview.cs
index 111f5446..d587b394 100644
--- a/Editor/PreviewSystem/NDMFPreview.cs
+++ b/Editor/PreviewSystem/NDMFPreview.cs
@@ -1,13 +1,18 @@
-using JetBrains.Annotations;
+#nullable enable
+
+using System.Collections.Immutable;
+using JetBrains.Annotations;
using nadena.dev.ndmf.preview.UI;
using nadena.dev.ndmf.ui;
using UnityEditor;
+using UnityEngine;
namespace nadena.dev.ndmf.preview
{
///
/// General utilities for controlling the NDMF preview system.
///
+ [PublicAPI]
// ReSharper disable once InconsistentNaming
public static class NDMFPreview
{
@@ -93,5 +98,23 @@ internal static void ForceResetPreview()
{
_globalPreviewSession.ForceRebuild();
}
+
+ ///
+ /// If the given game object is a preview proxy object, returns the original object that the proxy was created
+ /// for.
+ ///
+ /// The suspected proxy object
+ /// The original object, or null if the given object is not a proxy
+ public static GameObject? GetOriginalObjectForProxy(GameObject proxy)
+ {
+ var sess = PreviewSession.Current;
+
+ if (sess == null)
+ {
+ return null;
+ }
+
+ return sess.ProxyToOriginalObject.GetValueOrDefault(proxy);
+ }
}
}
\ No newline at end of file