private static void Init()
 {
     if (window == null)
     {
         window = (SearchForGUID)SearchableEditorWindow.GetWindow(typeof(SearchForGUID));
         window.Show();
     }
     else
     {
         window.SearchGUID();
     }
 }
Example #2
0
 private void OnEnable()
 {
     state             = (State)target;
     _serializedObject = new SerializedObject(state);
     list = new ReorderableList(_serializedObject, _serializedObject.FindProperty("pathes"), true, true, true, true);
     list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
     {
         rect.y += 2;
         EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), ((State)target).pathes[index].text);
         if (new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight).Contains(Event.current.mousePosition) && Event.current.type == EventType.mouseDown && Event.current.button == 0)
         {
             Selection.activeObject = list.serializedProperty.GetArrayElementAtIndex(index).objectReferenceValue as Path;
             Repaint();
         }
     };
     list.drawHeaderCallback = (Rect rect) =>
     {
         EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), "pathes");
     };
     list.onReorderCallback = (ReorderableList l) =>
     {
         Undo.RecordObject(state, "state path reorder");
         List <Path> newPathList = new List <Path>();
         for (int i = list.count - 1; i >= 0; i--)
         {
             newPathList.Add(l.serializedProperty.GetArrayElementAtIndex(i).objectReferenceValue as Path);
         }
         state.pathes = newPathList;
         SearchableEditorWindow.GetWindow(typeof(EditorWindow)).Repaint();
     };
     list.onAddCallback = (ReorderableList l) =>
     {
         AssetDatabase.AddObjectToAsset(state.AddPath(), AssetDatabase.GetAssetPath(state));
         Repaint();
         SearchableEditorWindow.GetWindow(typeof(EditorWindow)).Repaint();
     };
     list.onRemoveCallback = (ReorderableList l) =>
     {
         Undo.RecordObject(state, "state path remove");
         state.RemovePath(l.serializedProperty.GetArrayElementAtIndex(l.index).objectReferenceValue as Path);
         Undo.DestroyObjectImmediate(l.serializedProperty.GetArrayElementAtIndex(l.index).objectReferenceValue as Path);
         Repaint();
         EditorWindow.GetWindow(typeof(EditorWindow)).Repaint();
     };
 }