Skip to content

Commit f3deca4

Browse files
authored
Merge pull request #55 from eh-iart/main
2 parents a1cfb3c + f30c083 commit f3deca4

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

Editor/Drawers/CustomObjectDrawer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ private void HandleMouseDown(Rect position, Rect positionWithoutThumb, Serialize
8989
{
9090
isSelected = positionWithoutThumb.Contains(Event.mousePosition);
9191
ForceRepaintEditors();
92-
Clicked?.Invoke(property);
92+
if (isSelected)
93+
{
94+
Clicked?.Invoke(property);
95+
}
9396
}
9497
else if (Event.button == 1 && positionWithoutThumb.Contains(Event.mousePosition))
9598
{

Runtime/Extensions.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23

34
namespace TNRD
45
{
@@ -41,5 +42,21 @@ out TInterface value
4142
{
4243
return IsDefined(serializableInterface, out value);
4344
}
45+
46+
/// <summary>
47+
/// Convert a IEnumerable of Interfaces to a List of SerializableInterfaces
48+
/// </summary>
49+
public static List<SerializableInterface<T>> ToSerializableInterfaceList<T>(this IEnumerable<T> list) where T : class
50+
{
51+
return list.Select(e => new SerializableInterface<T>(e)).ToList();
52+
}
53+
54+
/// <summary>
55+
/// Convert a IEnumerable of Interfaces to an Array of SerializableInterfaces
56+
/// </summary>
57+
public static SerializableInterface<T>[] ToSerializableInterfaceArray<T>(this IEnumerable<T> list) where T : class
58+
{
59+
return list.Select(e => new SerializableInterface<T>(e)).ToArray();
60+
}
4461
}
4562
}

Runtime/SerializableInterface.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public class SerializableInterface<TInterface> : ISerializableInterface where TI
1515
[HideInInspector, SerializeField] private UnityEngine.Object unityReference;
1616
[SerializeReference, UsedImplicitly] private object rawReference;
1717

18+
public SerializableInterface()
19+
{
20+
}
21+
22+
public SerializableInterface(TInterface value)
23+
{
24+
Value = value;
25+
}
26+
1827
public TInterface Value
1928
{
2029
get

0 commit comments

Comments
 (0)