RetrieveLastSelected() public method

public RetrieveLastSelected ( ) : Patch
return Patch
Ejemplo n.º 1
0
        protected virtual void OnEnable()
        {
            ResetSelection();
            _patchManager = new PatchManager();
            _nodeFactory  = new NodeFactory();
            _patchManager.Reset();
            _patch = _patchManager.RetrieveLastSelected();

            Undo.undoRedoPerformed += OnUndo;
            EditorApplication.hierarchyWindowChanged += OnHierarchyWindowChanged;
        }
Ejemplo n.º 2
0
        void OnEnable()
        {
            _patchManager = new PatchManager();
            _nodeFactory  = new NodeFactory();
            _mainViewSize = Vector2.one * 300; // minimum view size

            _patchManager.Reset();
            _patch = _patchManager.RetrieveLastSelected();

            Undo.undoRedoPerformed += OnUndo;
            EditorApplication.hierarchyWindowChanged += OnHierarchyWindowChanged;
        }
Ejemplo n.º 3
0
        // Reset the internal state.
        void ResetState()
        {
            _patchManager.Reset();

            if (_patch == null || !_patch.isValid)
            {
                _patch = _patchManager.RetrieveLastSelected();
            }
            else
            {
                _patch.Rescan();
            }

            _mainViewSize = Vector2.one * 300; // minimum view size

            Repaint();
        }
Ejemplo n.º 4
0
        void OnGUI()
        {
            // Do nothing while play mode.
            if (isPlayMode)
            {
                DrawPlaceholderGUI("Not available in play mode");
                return;
            }

            // If there is something wrong with the patch manager, reset it.
            if (!_patchManager.isValid)
            {
                _patchManager.Reset();
            }

            // Patch validity check.
            if (_patch != null)
            {
                if (!_patch.isValid)
                {
                    _patch = null; // Seems like not good. Abandon it.
                }
                else if (!_patch.CheckNodesValidity())
                {
                    _patch.Rescan(); // Some nodes are not good. Rescan them.
                }
            }
            // Get a patch if no one is selected.
            if (_patch == null)
            {
                _patch = _patchManager.RetrieveLastSelected();
            }

            // Draw a placeholder if no patch is available.
            // Disable GUI during the play mode, or when no patch is available.
            if (_patch == null)
            {
                DrawPlaceholderGUI("No patch available");
                return;
            }

            // Tool bar
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            // - Create node menu
            _nodeFactory.CreateNodeMenuGUI(_patch);
            GUILayout.Space(100);

            // - Patch selector
            var patchIndex    = _patchManager.GetIndexOf(_patch);
            var newPatchIndex = EditorGUILayout.Popup(
                patchIndex, _patchManager.MakeNameList(),
                EditorStyles.toolbarDropDown
                );

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            // View area
            EditorGUILayout.BeginHorizontal();

            // - Main view
            DrawMainViewGUI();

            // - Side view (property editor)
            DrawSideBarGUI();

            EditorGUILayout.EndHorizontal();

            // Re-initialize the editor if the patch selection was changed.
            if (patchIndex != newPatchIndex)
            {
                _patch = _patchManager.RetrieveAt(newPatchIndex);
                _patchManager.Select(_patch);
                Repaint();
            }

            // Cancel wiring with a mouse click or hitting the esc key.
            if (_wiring != null)
            {
                var e = Event.current;
                if (e.type == EventType.MouseUp ||
                    (e.type == EventType.KeyDown && e.keyCode == KeyCode.Escape))
                {
                    _wiring = null;
                    e.Use();
                }
            }
        }
Ejemplo n.º 5
0
        void OnEnable()
        {
            _patchManager = new PatchManager();
            _nodeFactory = new NodeFactory();
            _mainViewSize = Vector2.one * 300; // minimum view size

            _patchManager.Reset();
            _patch = _patchManager.RetrieveLastSelected();

            Undo.undoRedoPerformed += OnUndo;
            EditorApplication.hierarchyWindowChanged += OnHierarchyWindowChanged;
        }
Ejemplo n.º 6
0
        void OnGUI()
        {
            if (isPlayMode)
            {
                DrawPlaceholderGUI("Not available in play mode");
                return;
            }

            if (_patchManager == null)
            {
                return;
            }

            // If there is something wrong with the patch manager, reset it.
            if (!_patchManager.isValid)
            {
                _patchManager.Reset();
            }

            // Patch validity check.
            if (_patch != null)
            {
                if (!_patch.isValid)
                {
                    _patch = null; // Seems like not good. Abandon it.
                }
                else if (!_patch.CheckNodesValidity())
                {
                    _patch.Rescan(); // Some nodes are not good. Rescan them.
                }
            }
            // Get a patch if no one is selected.
            if (_patch == null)
            {
                _patch = _patchManager.RetrieveLastSelected();
            }


            if (_patch == null && Selection.activeGameObject != null)
            {
                var p = Selection.activeGameObject.GetComponent <Klak.Wiring.Patch>();
                if (p != null)
                {
                    _patch = new Patch(p);
                }
            }
            // Draw a placeholder if no patch is available.
            // Disable GUI during the play mode, or when no patch is available.
            if (_patch == null)
            {
                DrawPlaceholderGUI("No patch available");
                return;
            }

            //if (Event.current.isKey)
            //{
            //    if (Event.current.keyCode == KeyCode.Escape)
            //    {
            //        Node._activeWindowID = -1;
            //        EditorGUIUtility.keyboardControl = 0;
            //    }
            //}
            DrawGUI();
        }