Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Editor/Drawers/CustomObjectDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
17 changes: 17 additions & 0 deletions Runtime/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;

namespace TNRD
{
Expand Down Expand Up @@ -41,5 +42,21 @@ out TInterface value
{
return IsDefined(serializableInterface, out value);
}

/// <summary>
/// Convert a IEnumerable of Interfaces to a List of SerializableInterfaces
/// </summary>
public static List<SerializableInterface<T>> ToSerializableInterfaceList<T>(this IEnumerable<T> list) where T : class
{
return list.Select(e => new SerializableInterface<T>(e)).ToList();
}

/// <summary>
/// Convert a IEnumerable of Interfaces to an Array of SerializableInterfaces
/// </summary>
public static SerializableInterface<T>[] ToSerializableInterfaceArray<T>(this IEnumerable<T> list) where T : class
{
return list.Select(e => new SerializableInterface<T>(e)).ToArray();
}
}
}
9 changes: 9 additions & 0 deletions Runtime/SerializableInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ public class SerializableInterface<TInterface> : 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
Expand Down