浏览代码

Editor window event fix

/main
Zakhar Ipatov 4 年前
当前提交
badd647a
共有 1 个文件被更改,包括 39 次插入28 次删除
  1. 67
      UOP1_Project/Assets/Scripts/StateMachine/Editor/TransitionTableEditorWindow.cs

67
UOP1_Project/Assets/Scripts/StateMachine/Editor/TransitionTableEditorWindow.cs


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()
{

正在加载...
取消
保存