From 7def5364163f45d9bcb568e14070cc50e3759203 Mon Sep 17 00:00:00 2001 From: Elias Hodel Date: Thu, 5 Oct 2023 11:51:30 +0200 Subject: [PATCH 1/5] Add Constructor with value --- Runtime/SerializableInterface.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Runtime/SerializableInterface.cs b/Runtime/SerializableInterface.cs index a5a9224..2c9dd1c 100644 --- a/Runtime/SerializableInterface.cs +++ b/Runtime/SerializableInterface.cs @@ -15,6 +15,16 @@ public class SerializableInterface : ISerializableInterface where TI [HideInInspector, SerializeField] private UnityEngine.Object unityReference; [SerializeReference, UsedImplicitly] private object rawReference; + public SerializableInterface() + { + + } + public SerializableInterface(TInterface value) + { + Value = value; + } + + public TInterface Value { get From 07bc281476623d8fde949face08541e5c4385025 Mon Sep 17 00:00:00 2001 From: Elias Hodel Date: Thu, 5 Oct 2023 11:58:55 +0200 Subject: [PATCH 2/5] Add Extension to Convert Lists and Arrays to SerializableInterfaces --- Runtime/Extensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Runtime/Extensions.cs b/Runtime/Extensions.cs index d89b03f..23bec07 100644 --- a/Runtime/Extensions.cs +++ b/Runtime/Extensions.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; namespace TNRD { @@ -41,5 +42,22 @@ out TInterface value { return IsDefined(serializableInterface, out value); } + + /// + /// Convert a IEnumerable of Interfaces to a List of SerializableInterfaces + /// + public static List> ToSerializableInterfaceList(this IEnumerable list) where T : class + { + return list.Select(e => new SerializableInterface(e) ).ToList(); + } + + /// + /// Convert a IEnumerable of Interfaces to an Array of SerializableInterfaces + /// + public static SerializableInterface[] ToSerializableInterfaceArray(this IEnumerable list) where T : class + { + return list.Select(e => new SerializableInterface(e)).ToArray(); + } + } } From 3810466250d1d0878808a6c3e4682fbe3a48928d Mon Sep 17 00:00:00 2001 From: Elias Hodel Date: Fri, 6 Oct 2023 11:43:23 +0200 Subject: [PATCH 3/5] Only invoke Clicked for Selected Property Only invoke Clicked for a Property if the Mouse is in the Property's Rect. In case that the Property was part of an Array all Array Elements were being pinged. This resulted in Unity ignoring all Pings except the last, so it was basically useless. --- Editor/Drawers/CustomObjectDrawer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Editor/Drawers/CustomObjectDrawer.cs b/Editor/Drawers/CustomObjectDrawer.cs index 95ac69d..d253881 100644 --- a/Editor/Drawers/CustomObjectDrawer.cs +++ b/Editor/Drawers/CustomObjectDrawer.cs @@ -89,7 +89,10 @@ private void HandleMouseDown(Rect position, Rect positionWithoutThumb, Serialize { isSelected = positionWithoutThumb.Contains(Event.mousePosition); ForceRepaintEditors(); - Clicked?.Invoke(property); + if (isSelected) + { + Clicked?.Invoke(property); + } } else if (Event.button == 1 && positionWithoutThumb.Contains(Event.mousePosition)) { From 41392f9c609431e35cffb076c17f3775b23a3ee3 Mon Sep 17 00:00:00 2001 From: eh-iart <122373308+eh-iart@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:11:59 +0100 Subject: [PATCH 4/5] Apply formatting fixes from code review Co-authored-by: Christiaan Bloemendaal --- Runtime/Extensions.cs | 2 +- Runtime/SerializableInterface.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Runtime/Extensions.cs b/Runtime/Extensions.cs index 23bec07..3cdb0f0 100644 --- a/Runtime/Extensions.cs +++ b/Runtime/Extensions.cs @@ -48,7 +48,7 @@ out TInterface value /// public static List> ToSerializableInterfaceList(this IEnumerable list) where T : class { - return list.Select(e => new SerializableInterface(e) ).ToList(); + return list.Select(e => new SerializableInterface(e)).ToList(); } /// diff --git a/Runtime/SerializableInterface.cs b/Runtime/SerializableInterface.cs index 2c9dd1c..d7641dc 100644 --- a/Runtime/SerializableInterface.cs +++ b/Runtime/SerializableInterface.cs @@ -17,14 +17,12 @@ public class SerializableInterface : ISerializableInterface where TI public SerializableInterface() { - } + public SerializableInterface(TInterface value) { Value = value; } - - public TInterface Value { get From f30c0832005ced77e770d24271a6d78e24c30de6 Mon Sep 17 00:00:00 2001 From: eh-iart <122373308+eh-iart@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:12:03 +0100 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Christiaan Bloemendaal --- Runtime/Extensions.cs | 1 - Runtime/SerializableInterface.cs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Runtime/Extensions.cs b/Runtime/Extensions.cs index 3cdb0f0..f832c89 100644 --- a/Runtime/Extensions.cs +++ b/Runtime/Extensions.cs @@ -58,6 +58,5 @@ public static SerializableInterface[] ToSerializableInterfaceArray(this IE { return list.Select(e => new SerializableInterface(e)).ToArray(); } - } } diff --git a/Runtime/SerializableInterface.cs b/Runtime/SerializableInterface.cs index d7641dc..2376d77 100644 --- a/Runtime/SerializableInterface.cs +++ b/Runtime/SerializableInterface.cs @@ -23,6 +23,7 @@ public SerializableInterface(TInterface value) { Value = value; } + public TInterface Value { get