public static void GUIDConvert() { var input = InputWindow.CreateWindow("Input GUID"); input.Callback += s => { var path = AssetDatabase.GUIDToAssetPath(s); Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path); }; input.ShowModal(); }
private void OnEnable() { m_statesProp = serializedObject.FindProperty("States"); m_statesList = new ReorderableList(serializedObject, m_statesProp) { onAddCallback = list => { var input = InputWindow.CreateWindow("Create new state"); input.Callback += stateName => { if (string.IsNullOrEmpty(stateName)) { return; } var switcher = target as StateSwitcher; if (Array.Find(switcher.States, state => state.StateName == stateName) != null) { EditorUtility.DisplayDialog("ERROR", $"Duplicate state name : {stateName}", "OK"); return; } var index = m_statesProp.arraySize; m_statesProp.InsertArrayElementAtIndex(index); var arrElement = m_statesProp.GetArrayElementAtIndex(index); var stateNameProp = arrElement.FindPropertyRelative("StateName"); stateNameProp.stringValue = stateName; var actionsProp = arrElement.FindPropertyRelative("SwitcherActions"); actionsProp.ClearArray(); m_statesProp.serializedObject.ApplyModifiedProperties(); }; input.ShowModal(); }, onSelectCallback = list => { if (list.index < 0) { m_switcherActionList = null; } else { var property = m_statesProp.GetArrayElementAtIndex(list.index); var switcherActionsProp = property.FindPropertyRelative("SwitcherActions"); m_switcherActionList = CreateNewListUI(switcherActionsProp); } }, drawHeaderCallback = rect => { EditorGUI.LabelField(rect, "State List"); }, onRemoveCallback = list => { m_statesProp.DeleteArrayElementAtIndex(list.index); m_switcherActionList = null; } }; }