Fix: OnListViewChanged events for 2021

This commit is contained in:
Akeit0 2024-02-28 08:57:18 +09:00
parent d6ead526bf
commit df3f0a13c6
3 changed files with 9 additions and 12 deletions

View File

@ -88,7 +88,7 @@ namespace Alchemy.Editor
if (events.OnItemsChosen == null) return; if (events.OnItemsChosen == null) return;
ReflectionHelper.Invoke(target, events.OnItemsChosen, new object[] { items }); ReflectionHelper.Invoke(target, events.OnItemsChosen, new object[] { items });
}; };
#elif UNITY_2022_1_OR_NEWER #else
listView.onItemsChosen += items => listView.onItemsChosen += items =>
{ {
if (events.OnItemsChosen == null) return; if (events.OnItemsChosen == null) return;
@ -113,8 +113,8 @@ namespace Alchemy.Editor
if (events.OnSelectedIndicesChanged== null) return; if (events.OnSelectedIndicesChanged== null) return;
ReflectionHelper.Invoke(target, events.OnSelectedIndicesChanged, new object[] { indices }); ReflectionHelper.Invoke(target, events.OnSelectedIndicesChanged, new object[] { indices });
}; };
#elif UNITY_2022_1_OR_NEWER #else
listView.onSelectionChanged += items => listView.onSelectionChange += items =>
{ {
if (events.OnSelectionChanged == null) return; if (events.OnSelectionChanged == null) return;
ReflectionHelper.Invoke(target, events.OnSelectionChanged, new object[] { items }); ReflectionHelper.Invoke(target, events.OnSelectionChanged, new object[] { items });

View File

@ -225,13 +225,13 @@ namespace Alchemy.Inspector
public string OnItemIndexChanged { get; set; } public string OnItemIndexChanged { get; set; }
public string OnItemsAdded { get; set; } public string OnItemsAdded { get; set; }
public string OnItemsRemoved { get; set; } public string OnItemsRemoved { get; set; }
#if UNITY_2022_1_OR_NEWER
public string OnItemsChosen { get; set; } public string OnItemsChosen { get; set; }
#endif
public string OnItemsSourceChanged { get; set; } public string OnItemsSourceChanged { get; set; }
#if UNITY_2022_1_OR_NEWER
public string OnSelectionChanged { get; set; } public string OnSelectionChanged { get; set; }
public string OnSelectedIndicesChanged { get; set; } public string OnSelectedIndicesChanged { get; set; }
#endif
} }
} }

View File

@ -8,10 +8,7 @@ public class OnListViewChangedTest : MonoBehaviour
OnItemChanged = nameof(OnItemChanged), OnItemChanged = nameof(OnItemChanged),
OnItemsAdded = nameof(OnItemsAdded), OnItemsAdded = nameof(OnItemsAdded),
OnItemsRemoved = nameof(OnItemsRemoved), OnItemsRemoved = nameof(OnItemsRemoved),
#if UNITY_2022_1_OR_NEWER
OnSelectedIndicesChanged = nameof(OnSelectedIndicesChanged), OnSelectedIndicesChanged = nameof(OnSelectedIndicesChanged),
#endif
OnItemIndexChanged = nameof(OnItemIndexChanged)) OnItemIndexChanged = nameof(OnItemIndexChanged))
] ]
public int[] array; public int[] array;
@ -30,12 +27,12 @@ public class OnListViewChangedTest : MonoBehaviour
{ {
Debug.Log($"Removed: [{string.Join(',', indices)}]"); Debug.Log($"Removed: [{string.Join(',', indices)}]");
} }
#if UNITY_2022_1_OR_NEWER
void OnSelectedIndicesChanged(IEnumerable<int> indices) void OnSelectedIndicesChanged(IEnumerable<int> indices)
{ {
Debug.Log($"Selected: [{string.Join(',', indices)}]"); Debug.Log($"Selected: [{string.Join(',', indices)}]");
} }
#endif
void OnItemIndexChanged(int before, int after) void OnItemIndexChanged(int before, int after)
{ {
Debug.Log($"Index Changed: [{before} -> {after}]"); Debug.Log($"Index Changed: [{before} -> {after}]");