Example #1
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        AddFinder window = (AddFinder)EditorWindow.GetWindow(typeof(AddFinder));

        window.Show();
    }
Example #2
0
    void OnGUI()
    {
        if (EditorApplication.isPlaying)
        {
            return;
        }

        if (GUILayout.Button("Add Finder...", GUILayout.Height(_buttonSize)))
        {
            if (addingWidow == null)
            {
                addingWidow = ScriptableObject.CreateInstance <AddFinder>();
            }
            addingWidow.Show();
        }

        if (_allFinders == null)
        {
            _allFinders = new List <AFinder>();
            LoadList();
        }

        for (int i = 0; i < _allFinders.Count; i++)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label(_allFinders[i].name, EditorStyles.boldLabel);

            if (_allFinders[i].instance == null)
            {
                GUILayout.Label("ERROR, INSTANCE NOT FOUND", EditorStyles.boldLabel);
            }
            else
            {
                if (GUILayout.Button("FIND !", GUILayout.Height(_buttonSize)))
                {
                    Selection.activeGameObject = _allFinders[i].instance;
                    SceneView view = SceneView.lastActiveSceneView;
                    if (view != null)
                    {
                        view.pivot = _allFinders[i].instance.transform.position;
                    }
                }
            }

            if (GUILayout.Button("X", GUILayout.Height(_buttonSize), GUILayout.Width(_buttonSize)))
            {
                _allFinders.RemoveAt(i);
            }

            GUILayout.EndHorizontal();
        }

        if (GUILayout.Button("Save Finders !", GUILayout.Height(_buttonSize)))
        {
            SaveList();
        }

        if (GUILayout.Button("Load Finders !", GUILayout.Height(_buttonSize)))
        {
            if (_allFinders.Count != 0)
            {
                _allFinders.Clear();
            }
            LoadList();
        }
    }