|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using UnityEditor; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.UIElements; |
|
|
|
|
|
|
_doRefresh = true; |
|
|
|
} |
|
|
|
|
|
|
|
private void OnLostFocus() |
|
|
|
{ |
|
|
|
ListView listView = rootVisualElement.Q<ListView>(className: "table-list"); |
|
|
|
listView.onSelectionChanged -= OnListSelectionChanged; |
|
|
|
} |
|
|
|
|
|
|
|
private void Update() |
|
|
|
{ |
|
|
|
if (!_doRefresh) |
|
|
|
|
|
|
listView.bindItem = (element, i) => ((Label)element).text = assets[i].name; |
|
|
|
listView.selectionType = SelectionType.Single; |
|
|
|
|
|
|
|
listView.onSelectionChanged += enumerable => |
|
|
|
{ |
|
|
|
IMGUIContainer editor = rootVisualElement.Q<IMGUIContainer>(className: "table-editor"); |
|
|
|
editor.onGUIHandler = null; |
|
|
|
listView.onSelectionChanged += OnListSelectionChanged; |
|
|
|
} |
|
|
|
if (enumerable.Count == 0) |
|
|
|
return; |
|
|
|
private void OnListSelectionChanged(List<object> list) |
|
|
|
{ |
|
|
|
IMGUIContainer editor = rootVisualElement.Q<IMGUIContainer>(className: "table-editor"); |
|
|
|
editor.onGUIHandler = null; |
|
|
|
var table = (TransitionTableSO)enumerable[0]; |
|
|
|
if (table == null) |
|
|
|
if (list.Count == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
var table = (TransitionTableSO)list[0]; |
|
|
|
if (table == null) |
|
|
|
return; |
|
|
|
|
|
|
|
if (_transitionTableEditor == null) |
|
|
|
_transitionTableEditor = UnityEditor.Editor.CreateEditor(table, typeof(TransitionTableEditor)); |
|
|
|
else |
|
|
|
UnityEditor.Editor.CreateCachedEditor(table, typeof(TransitionTableEditor), ref _transitionTableEditor); |
|
|
|
|
|
|
|
editor.onGUIHandler = () => |
|
|
|
{ |
|
|
|
if (!_transitionTableEditor.target) |
|
|
|
{ |
|
|
|
editor.onGUIHandler = null; |
|
|
|
} |
|
|
|
if (_transitionTableEditor == null) |
|
|
|
_transitionTableEditor = UnityEditor.Editor.CreateEditor(table, typeof(TransitionTableEditor)); |
|
|
|
else |
|
|
|
UnityEditor.Editor.CreateCachedEditor(table, typeof(TransitionTableEditor), ref _transitionTableEditor); |
|
|
|
|
|
|
|
editor.onGUIHandler = () => |
|
|
|
ListView listView = rootVisualElement.Q<ListView>(className: "table-list"); |
|
|
|
if ((Object)listView.selectedItem != _transitionTableEditor.target) |
|
|
|
if (!_transitionTableEditor.target) |
|
|
|
var i = listView.itemsSource.IndexOf(_transitionTableEditor.target); |
|
|
|
listView.selectedIndex = i; |
|
|
|
if (i < 0) |
|
|
|
|
|
|
|
if ((Object)listView.selectedItem != _transitionTableEditor.target) |
|
|
|
{ |
|
|
|
var i = listView.itemsSource.IndexOf(_transitionTableEditor.target); |
|
|
|
listView.selectedIndex = i; |
|
|
|
if (i < 0) |
|
|
|
{ |
|
|
|
editor.onGUIHandler = null; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
_transitionTableEditor.OnInspectorGUI(); |
|
|
|
}; |
|
|
|
_transitionTableEditor.OnInspectorGUI(); |
|
|
|
|
|
|
|
|
|
|
|
private TransitionTableSO[] FindAssets() |
|
|
|
{ |
|
|
|