com.unity.uiextensions/Runtime/Scripts/Controls/ReorderableList/ReorderableListDebug.cs

33 lines
1.3 KiB
C#
Raw Normal View History

/// Credit Ziboo
/// Sourced from - http://forum.unity3d.com/threads/free-reorderable-list.364600/
namespace UnityEngine.UI.Extensions
{
public class ReorderableListDebug : MonoBehaviour
{
2023-02-04 19:22:31 +08:00
#if UNITY_2022_1_OR_NEWER
public TMPro.TMP_Text DebugLabel;
#else
public Text DebugLabel;
2023-02-04 19:22:31 +08:00
#endif
void Awake()
{
foreach (var list in FindObjectsOfType<ReorderableList>())
{
list.OnElementDropped.AddListener(ElementDropped);
}
}
private void ElementDropped(ReorderableList.ReorderableListEventStruct droppedStruct)
{
DebugLabel.text = "";
DebugLabel.text += "Dropped Object: " + droppedStruct.DroppedObject.name + "\n";
DebugLabel.text += "Is Clone ?: " + droppedStruct.IsAClone + "\n";
if (droppedStruct.IsAClone)
DebugLabel.text += "Source Object: " + droppedStruct.SourceObject.name + "\n";
DebugLabel.text += string.Format("From {0} at Index {1} \n", droppedStruct.FromList.name, droppedStruct.FromIndex);
DebugLabel.text += string.Format("To {0} at Index {1} \n", droppedStruct.ToList == null ? "Empty space" : droppedStruct.ToList.name, droppedStruct.ToIndex);
}
}
}