From 4423f0ff91fb74a2d8742bfb6e4b3eee5863f20d Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:58:38 +0200 Subject: [PATCH] Doesn't work in inspector --- RuntimeUnityEditor/Features/ContextMenu.cs | 18 +++- .../Windows/Clipboard/ClipboardWindow.cs | 92 ++++++++++++++++++- .../Entries/Contents/CacheEntryBase.cs | 4 +- .../Entries/Contents/CallbackCacheEntey.cs | 4 +- .../Entries/Contents/EventCacheEntry.cs | 10 +- .../Entries/Contents/FieldCacheEntry.cs | 4 +- .../Inspector/Entries/Contents/ICacheEntry.cs | 4 + .../Entries/Contents/ListCacheEntry.cs | 2 +- .../Entries/Contents/MethodCacheEntry.cs | 11 ++- .../Entries/Contents/PropertyCacheEntry.cs | 4 +- .../Entries/Contents/ReadonlyCacheEntry.cs | 2 +- .../Entries/Inspector/InstanceStackEntry.cs | 2 +- .../Entries/Inspector/StaticStackEntry.cs | 2 +- .../Inspector/Inspector.InspectorTab.cs | 4 +- .../Windows/Inspector/Inspector.cs | 2 +- .../Windows/Inspector/VariableFieldDrawer.cs | 8 +- .../Windows/ObjectTree/ObjectTreeViewer.cs | 4 +- .../Windows/ObjectView/ObjectViewWindow.cs | 2 +- .../Windows/Profiler/ProfilerWindow.cs | 2 +- 19 files changed, 142 insertions(+), 39 deletions(-) diff --git a/RuntimeUnityEditor/Features/ContextMenu.cs b/RuntimeUnityEditor/Features/ContextMenu.cs index eb731de..e0e43b1 100644 --- a/RuntimeUnityEditor/Features/ContextMenu.cs +++ b/RuntimeUnityEditor/Features/ContextMenu.cs @@ -22,6 +22,7 @@ public class ContextMenu : FeatureBase { private object _obj; private MemberInfo _objMemberInfo; + private object _objMemberInstance; private string _objName; private Rect _windowRect; @@ -80,6 +81,10 @@ protected override void Initialize(InitSettings initSettings) if (Clipboard.ClipboardWindow.Contents.LastOrDefault() != o) Clipboard.ClipboardWindow.Contents.Add(o); }), + new MenuEntry("Paste from clipboard", o => _objMemberInfo != null && Clipboard.ClipboardWindow.Initialized && Clipboard.ClipboardWindow.Contents.Any(), o => + { + Clipboard.ClipboardWindow.Instance.EnterPasteMode(o, _objMemberInfo, _objMemberInstance); + }), //todo Paste from clipboard, kind of difficult new MenuEntry("Export texture...", @@ -164,10 +169,11 @@ o is Sprite || /// /// Object to show the menu for. Set to null to hide the menu. /// MemberInfo of wherever the object came from. Can be null. - public void Show(object obj, MemberInfo objMemberInfo) + /// Instance of wherever the object came from. Can be null for static. + public void Show(object obj, MemberInfo objMemberInfo, object objMemberInstance) { var m = UnityInput.Current.mousePosition; - Show(obj, objMemberInfo, new Vector2(m.x, Screen.height - m.y)); + Show(obj, objMemberInfo, objMemberInstance, new Vector2(m.x, Screen.height - m.y)); } /// @@ -175,8 +181,9 @@ public void Show(object obj, MemberInfo objMemberInfo) /// /// Object to show the menu for. Set to null to hide the menu. /// MemberInfo of wherever the object came from. Can be null. + /// Instance of wherever the object came from. Can be null for static. /// Screen position to show the menu at. - public void Show(object obj, MemberInfo objMemberInfo, Vector2 clickPoint) + public void Show(object obj, MemberInfo objMemberInfo, object objMemberInstance, Vector2 clickPoint) { _windowRect = new Rect(clickPoint, new Vector2(100, 100)); @@ -184,6 +191,7 @@ public void Show(object obj, MemberInfo objMemberInfo, Vector2 clickPoint) { _obj = obj; _objMemberInfo = objMemberInfo; + _objMemberInstance = objMemberInstance; _objName = objMemberInfo != null ? $"{objMemberInfo.DeclaringType?.Name}.{objMemberInfo.Name}" : obj.GetType().FullDescription(); _currentContents = MenuContents.Where(x => x.IsVisible(_obj)).ToList(); @@ -203,10 +211,10 @@ public void Show(object obj, MemberInfo objMemberInfo, Vector2 clickPoint) /// /// Draw a GUILayout button that opens the context menu when clicked. It's only shown if the object is not null. /// - public void DrawContextButton(object obj, MemberInfo objMemberInfo) + public void DrawContextButton(object obj, MemberInfo objMemberInfo, object objMemberInstance) { if (obj != null && GUILayout.Button("...", GUILayout.ExpandWidth(false))) - Show(obj, objMemberInfo); + Show(obj, objMemberInfo, objMemberInstance); } /// diff --git a/RuntimeUnityEditor/Windows/Clipboard/ClipboardWindow.cs b/RuntimeUnityEditor/Windows/Clipboard/ClipboardWindow.cs index 2367d68..3ccba7f 100644 --- a/RuntimeUnityEditor/Windows/Clipboard/ClipboardWindow.cs +++ b/RuntimeUnityEditor/Windows/Clipboard/ClipboardWindow.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Reflection; using RuntimeUnityEditor.Core.Inspector; using RuntimeUnityEditor.Core.Inspector.Entries; using RuntimeUnityEditor.Core.Utils; @@ -21,6 +22,11 @@ public class ClipboardWindow : Window public static readonly List Contents = new List(); private Vector2 _scrollPos; + private string _pasteModeCurrentValueString; + private MemberInfo _pasteModeMemberInfo; + private object _pasteModeOwnerInstance; + public bool InPasteMode => _pasteModeMemberInfo != null; + protected override void Initialize(InitSettings initSettings) { Title = "Clipboard"; @@ -32,8 +38,12 @@ protected override void DrawContents() { _scrollPos = GUILayout.BeginScrollView(_scrollPos, false, true); + var inPasteMode = InPasteMode; + if (Contents.Count == 0) { + if (inPasteMode) ExitPasteMode(); + GUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); @@ -49,6 +59,14 @@ protected override void DrawContents() // Draw clipboard items GUILayout.BeginVertical(); { + if (inPasteMode) + { + GUILayout.BeginHorizontal(); + GUILayout.Label($"Select which value to paste into {_pasteModeMemberInfo.GetFancyDescription()} (current value: {_pasteModeCurrentValueString ?? "NULL"})"); + if (GUILayout.Button("Cancel")) ExitPasteMode(); + GUILayout.EndHorizontal(); + } + const int widthIndex = 35; const int widthName = 70; @@ -66,13 +84,23 @@ protected override void DrawContents() { var content = Contents[index]; - if (GUILayout.Button(index.ToString(), GUI.skin.label, GUILayout.Width(widthIndex), GUILayout.ExpandWidth(false)) && IMGUIUtils.IsMouseRightClick()) - ContextMenu.Instance.Show(content, null); + if (inPasteMode) + { + if (GUILayout.Button("Paste", GUILayout.Width(widthIndex), GUILayout.ExpandWidth(false))) + { + DoPaste(content); + } + } + else + { + if (GUILayout.Button(index.ToString(), GUI.skin.label, GUILayout.Width(widthIndex), GUILayout.ExpandWidth(false)) && IMGUIUtils.IsMouseRightClick()) + ContextMenu.Instance.Show(content, null, null); + } var type = content?.GetType(); if (GUILayout.Button(type?.Name ?? "NULL", GUI.skin.label, GUILayout.Width(widthName), GUILayout.ExpandWidth(false)) && IMGUIUtils.IsMouseRightClick()) - ContextMenu.Instance.Show(content, null); + ContextMenu.Instance.Show(content, null, null); var prevEnabled = GUI.enabled; GUI.enabled = type != null && typeof(IConvertible).IsAssignableFrom(type); @@ -103,5 +131,63 @@ protected override void DrawContents() GUILayout.EndScrollView(); } + + private void DoPaste(object content) + { + switch (_pasteModeMemberInfo) + { + case PropertyInfo propertyInfo: + propertyInfo.SetValue(_pasteModeOwnerInstance, content, null); + break; + case FieldInfo fieldInfo: + fieldInfo.SetValue(_pasteModeOwnerInstance, content); + break; + } + + ExitPasteMode(); + } + + public void EnterPasteMode(object currentValue, MemberInfo memberInfo, object ownerInstance) + { + if (Contents.Count == 0 || memberInfo == null) + { + ExitPasteMode(); + return; + } + + switch (memberInfo) + { + case PropertyInfo propertyInfo: + if (!propertyInfo.CanWrite) + { + ExitPasteMode(); + return; + } + + break; + case FieldInfo fieldInfo: + if (fieldInfo.IsLiteral) + { + ExitPasteMode(); + return; + } + + break; + default: + ExitPasteMode(); + return; + } + + _pasteModeCurrentValueString = currentValue?.ToString() ?? "NULL"; + _pasteModeMemberInfo = memberInfo; + _pasteModeOwnerInstance = ownerInstance; + } + + public void ExitPasteMode() + { + _pasteModeCurrentValueString = null; + _pasteModeMemberInfo = null; + _pasteModeOwnerInstance = null; + } } } diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CacheEntryBase.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CacheEntryBase.cs index e57509e..5ef4796 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CacheEntryBase.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CacheEntryBase.cs @@ -9,11 +9,12 @@ public abstract class CacheEntryBase : ICacheEntry // todo add gui option public static bool CachingEnabled { get; set; } = false; - protected CacheEntryBase(string name, string description, Type owner = null) + protected CacheEntryBase(string name, string description, Type owner, object ownerInstance) { Owner = owner; _name = name; _nameContent = new GUIContent(_name, description + "\n\nLeft click to inspect in current tab\nMiddle click to inspect in a new tab\nRight click to open a menu with more options"); + OwnerInstance = ownerInstance; } public GUIContent GetNameContent() => _nameContent; @@ -48,6 +49,7 @@ public void SetValue(object newValue) private readonly string _name; private string _typeName; public Type Owner { get; } + public object OwnerInstance { get; } public string Name() => _name; diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CallbackCacheEntey.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CallbackCacheEntey.cs index 45a8579..98e59fa 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CallbackCacheEntey.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/CallbackCacheEntey.cs @@ -7,7 +7,7 @@ public class CallbackCacheEntry : CacheEntryBase private readonly string _message; private readonly Action _callback; - public CallbackCacheEntry(string name, string message, Action callback) : base(name, "RUE Callback / Feature") + public CallbackCacheEntry(string name, string message, Action callback) : base(name, "RUE Callback / Feature", null, null) { _message = message; _callback = callback ?? throw new ArgumentNullException(nameof(callback)); @@ -50,7 +50,7 @@ public class CallbackCacheEntry : CacheEntryBase private readonly string _message; private readonly Func _callback; - public CallbackCacheEntry(string name, string message, Func callback) : base(name, "RUE Callback / Feature") + public CallbackCacheEntry(string name, string message, Func callback) : base(name, "RUE Callback / Feature", null, null) { _message = message; _callback = callback ?? throw new ArgumentNullException(nameof(callback)); diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/EventCacheEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/EventCacheEntry.cs index 849c896..32642cb 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/EventCacheEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/EventCacheEntry.cs @@ -6,19 +6,19 @@ namespace RuntimeUnityEditor.Core.Inspector.Entries { public class EventCacheEntry : CacheEntryBase { - public object Instance { get; } + [Obsolete] + public object Instance => OwnerInstance; public EventInfo EventInfo { get; } - public EventCacheEntry(object ins, EventInfo e, Type owner) : base(FieldCacheEntry.GetMemberName(ins, e), e.GetFancyDescription(), owner) + public EventCacheEntry(object ownerInstance, EventInfo e, Type owner) : base(FieldCacheEntry.GetMemberName(ownerInstance, e), e.GetFancyDescription(), owner, ownerInstance) { if (owner == null) throw new ArgumentNullException(nameof(owner)); - Instance = ins; EventInfo = e ?? throw new ArgumentNullException(nameof(e)); - BackingField = owner.GetField(e.Name, BindingFlags.NonPublic | (ins == null ? BindingFlags.Static : BindingFlags.Instance)); + BackingField = owner.GetField(e.Name, BindingFlags.NonPublic | (ownerInstance == null ? BindingFlags.Static : BindingFlags.Instance)); } public FieldInfo BackingField { get; } public override bool CanEnterValue() => BackingField != null; - public override object GetValueToCache() => BackingField?.GetValue(Instance); + public override object GetValueToCache() => BackingField?.GetValue(OwnerInstance); protected override bool OnSetValue(object newValue) => throw new InvalidOperationException(); public override Type Type() => EventInfo.EventHandlerType; public override bool CanSetValue() => false; diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/FieldCacheEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/FieldCacheEntry.cs index 1b94668..1c5b6d1 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/FieldCacheEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/FieldCacheEntry.cs @@ -6,8 +6,8 @@ namespace RuntimeUnityEditor.Core.Inspector.Entries { public class FieldCacheEntry : CacheEntryBase { - public FieldCacheEntry(object ins, FieldInfo f, Type owner) : this(ins, f, owner, null) { } - public FieldCacheEntry(object ins, FieldInfo f, Type owner, ICacheEntry parent) : base(GetMemberName(ins, f), f.GetFancyDescription(), owner) + public FieldCacheEntry(object ins, FieldInfo f, Type owner, object ownerInstance) : this(ins, f, owner, ownerInstance, null) { } + public FieldCacheEntry(object ins, FieldInfo f, Type owner, object ownerInstance, ICacheEntry parent) : base(GetMemberName(ins, f), f.GetFancyDescription(), owner, ownerInstance) { _instance = ins; FieldInfo = f ?? throw new ArgumentNullException(nameof(f)); diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ICacheEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ICacheEntry.cs index 23bac30..d0edf6b 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ICacheEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ICacheEntry.cs @@ -25,6 +25,10 @@ public interface ICacheEntry /// Type Owner { get; } /// + /// Instance of type that owns this member. + /// + object OwnerInstance { get; } + /// /// Get object that is entered when variable name is clicked in inspector /// object EnterValue(); diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ListCacheEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ListCacheEntry.cs index e61eae6..1321695 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ListCacheEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ListCacheEntry.cs @@ -10,7 +10,7 @@ public class ListCacheEntry : CacheEntryBase private readonly IList _list; private readonly int _index; - public ListCacheEntry(IList container, int index) : base(ReadonlyListCacheEntry.GetListItemName(index), $"Item contained inside of a list.\n\nIndex: {index}\n\nList type: {container.GetType().FullDescription()}", null) + public ListCacheEntry(IList container, int index) : base(ReadonlyListCacheEntry.GetListItemName(index), $"Item contained inside of a list.\n\nIndex: {index}\n\nList type: {container.GetType().FullDescription()}", null, null) { _index = index; _list = container; diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/MethodCacheEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/MethodCacheEntry.cs index 4dd92bc..19feba3 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/MethodCacheEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/MethodCacheEntry.cs @@ -8,13 +8,16 @@ namespace RuntimeUnityEditor.Core.Inspector.Entries { public class MethodCacheEntry : ICacheEntry { - public MethodCacheEntry(object instance, MethodInfo methodInfo, Type owner) + [Obsolete] + public object Instance => OwnerInstance; + + public MethodCacheEntry(object ownerInstance, MethodInfo methodInfo, Type owner) { - Instance = instance; + OwnerInstance = ownerInstance; MethodInfo = methodInfo ?? throw new ArgumentNullException(nameof(methodInfo)); Owner = owner ?? throw new ArgumentNullException(nameof(owner)); - _name = FieldCacheEntry.GetMemberName(instance, methodInfo); + _name = FieldCacheEntry.GetMemberName(ownerInstance, methodInfo); _returnTypeName = MethodInfo.ReturnType.GetSourceCodeRepresentation(); ParameterString = GetParameterPreviewString(methodInfo); @@ -35,7 +38,7 @@ internal static string GetParameterPreviewString(MethodBase methodInfo) public MethodInfo MethodInfo { get; } public bool IsDeclared => Owner == MethodInfo.DeclaringType; public Type Owner { get; } - public object Instance { get; } + public object OwnerInstance { get; } public string ParameterString { get; } private readonly string _name; private readonly string _returnTypeName; diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/PropertyCacheEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/PropertyCacheEntry.cs index 33aa861..fdab8e7 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/PropertyCacheEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/PropertyCacheEntry.cs @@ -6,8 +6,8 @@ namespace RuntimeUnityEditor.Core.Inspector.Entries { public class PropertyCacheEntry : CacheEntryBase { - public PropertyCacheEntry(object ins, PropertyInfo p, Type owner) : this(ins, p, owner, null) { } - public PropertyCacheEntry(object ins, PropertyInfo p, Type owner, ICacheEntry parent) : base(FieldCacheEntry.GetMemberName(ins, p), p.GetFancyDescription(), owner) + public PropertyCacheEntry(object ins, PropertyInfo p, Type owner, object ownerInstance) : this(ins, p, owner,ownerInstance, null) { } + public PropertyCacheEntry(object ins, PropertyInfo p, Type owner, object ownerInstance, ICacheEntry parent) : base(FieldCacheEntry.GetMemberName(ins, p), p.GetFancyDescription(), owner, ownerInstance ?? parent.GetValue()) { _instance = ins; PropertyInfo = p ?? throw new ArgumentNullException(nameof(p)); diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ReadonlyCacheEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ReadonlyCacheEntry.cs index 196abd5..8d9d3f6 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ReadonlyCacheEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Contents/ReadonlyCacheEntry.cs @@ -8,7 +8,7 @@ public class ReadonlyCacheEntry : CacheEntryBase private readonly Type _type; private string _tostringCache; - public ReadonlyCacheEntry(string name, object obj) : base(name, "Read-only item (RUE-only, it doesn't actually exist).") + public ReadonlyCacheEntry(string name, object obj) : base(name, "Read-only item (RUE-only, it doesn't actually exist).", null, null) { Object = obj; _type = obj.GetType(); diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/InstanceStackEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/InstanceStackEntry.cs index e1485d2..393f04c 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/InstanceStackEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/InstanceStackEntry.cs @@ -20,7 +20,7 @@ public override bool EntryIsValid() public override void ShowContextMenu() { - ContextMenu.Instance.Show(Instance, Parent?.GetMemberInfo(false)); + ContextMenu.Instance.Show(Instance, Parent?.GetMemberInfo(false), Parent?.GetValue()); } } } \ No newline at end of file diff --git a/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/StaticStackEntry.cs b/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/StaticStackEntry.cs index 9e3776a..e89a6ad 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/StaticStackEntry.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Entries/Inspector/StaticStackEntry.cs @@ -17,7 +17,7 @@ public override bool EntryIsValid() public override void ShowContextMenu() { - ContextMenu.Instance.Show(StaticType, null); + ContextMenu.Instance.Show(StaticType, null, null); } } } \ No newline at end of file diff --git a/RuntimeUnityEditor/Windows/Inspector/Inspector.InspectorTab.cs b/RuntimeUnityEditor/Windows/Inspector/Inspector.InspectorTab.cs index 45c35cb..38f7984 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Inspector.InspectorTab.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Inspector.InspectorTab.cs @@ -211,11 +211,11 @@ private void CacheStaticMembersHelper(Type type) { _fieldCache.AddRange(type.GetAllFields(true) .Where(f => !f.IsDefined(typeof(CompilerGeneratedAttribute), false)) - .Select(f => new FieldCacheEntry(null, f, type)).Cast()); + .Select(f => new FieldCacheEntry(null, f, type, null)).Cast()); _fieldCache.AddRange(type.GetAllProperties(true) .Where(f => !f.IsDefined(typeof(CompilerGeneratedAttribute), false)) - .Select(p => new PropertyCacheEntry(null, p, type)).Cast()); + .Select(p => new PropertyCacheEntry(null, p, type, null)).Cast()); _fieldCache.AddRange(type.GetAllEvents(true) .Where(f => !f.IsDefined(typeof(CompilerGeneratedAttribute), false)) diff --git a/RuntimeUnityEditor/Windows/Inspector/Inspector.cs b/RuntimeUnityEditor/Windows/Inspector/Inspector.cs index f2ae50e..6a9a208 100644 --- a/RuntimeUnityEditor/Windows/Inspector/Inspector.cs +++ b/RuntimeUnityEditor/Windows/Inspector/Inspector.cs @@ -89,7 +89,7 @@ private void DrawVariableNameEnterButton(ICacheEntry field) if (IMGUIUtils.IsMouseRightClick()) { if (val != null) - ContextMenu.Instance.Show(val, field.GetMemberInfo(false)); + ContextMenu.Instance.Show(val, field.GetMemberInfo(false), field.OwnerInstance); } else if (canEnterValue || val is Exception) { diff --git a/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs b/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs index b9377ac..b8a872a 100644 --- a/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs +++ b/RuntimeUnityEditor/Windows/Inspector/VariableFieldDrawer.cs @@ -401,7 +401,7 @@ private static void DrawImage(ICacheEntry obj, object value) private static void DrawMethodInvokeField(MethodCacheEntry method) { if (GUILayout.Button(_buttonInvokeContent, GUILayout.ExpandWidth(false))) - ShowInvokeWindow(method.MethodInfo, method.Instance); + ShowInvokeWindow(method.MethodInfo, method.OwnerInstance); GUILayout.Label(method.ParameterString, GUILayout.ExpandWidth(true)); } @@ -411,15 +411,15 @@ private static void DrawEventInvokeField(EventCacheEntry @event) GUILayout.Label("Invoke event method: ", GUILayout.ExpandWidth(false)); if (GUILayout.Button("Add", GUILayout.ExpandWidth(false))) - ShowInvokeWindow(eventInfo.GetAddMethod(true), @event.Instance); + ShowInvokeWindow(eventInfo.GetAddMethod(true), @event.OwnerInstance); if (GUILayout.Button("Remove", GUILayout.ExpandWidth(false))) - ShowInvokeWindow(eventInfo.GetRemoveMethod(true), @event.Instance); + ShowInvokeWindow(eventInfo.GetRemoveMethod(true), @event.OwnerInstance); // Raise method is always null in C# assemblies, but exists if assembly was compiled from VB.NET, F# or C++/CLI var raiseMethod = eventInfo.GetRaiseMethod(true); if (raiseMethod != null && GUILayout.Button("Raise", GUILayout.ExpandWidth(false))) - ShowInvokeWindow(raiseMethod, @event.Instance); + ShowInvokeWindow(raiseMethod, @event.OwnerInstance); var backingDelegate = (Delegate)@event.GetValue(); if (backingDelegate != null) diff --git a/RuntimeUnityEditor/Windows/ObjectTree/ObjectTreeViewer.cs b/RuntimeUnityEditor/Windows/ObjectTree/ObjectTreeViewer.cs index 8f067ad..ed87a3a 100644 --- a/RuntimeUnityEditor/Windows/ObjectTree/ObjectTreeViewer.cs +++ b/RuntimeUnityEditor/Windows/ObjectTree/ObjectTreeViewer.cs @@ -175,7 +175,7 @@ private void DisplayObjectTreeHelper(GameObject go, int indent, ref int currentC { if (IMGUIUtils.IsMouseRightClick()) { - ContextMenu.Instance.Show(go, null); + ContextMenu.Instance.Show(go, null, null); } else { @@ -360,7 +360,7 @@ private void DrawSingleComponent(Component component) { if (IMGUIUtils.IsMouseRightClick()) { - ContextMenu.Instance.Show(component, null); + ContextMenu.Instance.Show(component, null, null); } else { diff --git a/RuntimeUnityEditor/Windows/ObjectView/ObjectViewWindow.cs b/RuntimeUnityEditor/Windows/ObjectView/ObjectViewWindow.cs index 937049e..e0596bb 100644 --- a/RuntimeUnityEditor/Windows/ObjectView/ObjectViewWindow.cs +++ b/RuntimeUnityEditor/Windows/ObjectView/ObjectViewWindow.cs @@ -83,7 +83,7 @@ protected override void DrawContents() { GUILayout.BeginHorizontal(); { - ContextMenu.Instance.DrawContextButton(_objToDisplay, null); + ContextMenu.Instance.DrawContextButton(_objToDisplay, null, null); } GUILayout.EndHorizontal(); diff --git a/RuntimeUnityEditor/Windows/Profiler/ProfilerWindow.cs b/RuntimeUnityEditor/Windows/Profiler/ProfilerWindow.cs index 79aa114..eb203e0 100644 --- a/RuntimeUnityEditor/Windows/Profiler/ProfilerWindow.cs +++ b/RuntimeUnityEditor/Windows/Profiler/ProfilerWindow.cs @@ -188,7 +188,7 @@ protected override void DrawContents() GUILayout.FlexibleSpace(); - ContextMenu.Instance.DrawContextButton(pd.Owner, pd.Method); + ContextMenu.Instance.DrawContextButton(pd.Owner, pd.Method, null); if (DnSpyHelper.IsAvailable && GUILayout.Button("^")) DnSpyHelper.OpenInDnSpy(pd.Method); } GUILayout.EndHorizontal();