示例#1
0
        void OnGUI()
        {
            // Disable GUI during the play mode, or when no patch is available.
            if (isPlayMode || _patch == null)
            {
                DrawNoPatchMessage();
                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();
                }
            }
        }
        // Process feedback from the leaf UI elemets.
        void ProcessUIFeedback(FeedbackQueue.RecordBase record)
        {
            // Delete request
            if (record is FeedbackQueue.DeleteNodeRecord)
            {
                var removeNode = ((FeedbackQueue.DeleteNodeRecord)record).node;
                if (Node.ActiveNode == removeNode)
                {
                    Node.ActiveNode = null;
                }
                // Remove related links.
                foreach (var node in _patch.nodeList)
                {
                    node.RemoveLinksTo(removeNode, _patch);
                }

                // Remove the node.
                removeNode.RemoveFromPatch(_patch);

                // Rescan the patch and repaint.
                _patch.Rescan();
                Repaint();
            }
            // Inlet button pressed
            if (record is FeedbackQueue.InletButtonRecord)
            {
                var info = (FeedbackQueue.InletButtonRecord)record;
                if (_wiring == null)
                {
                    _wiring = new WiringState(info.node, info.inlet);
                }
                else
                {
                    // Currently in wiring: try to make a link.
                    _wiring.node.TryLinkTo(_wiring.outlet, info.node, info.inlet);
                    _wiring = null;
                }
            }

            // Outlet button pressed
            if (record is FeedbackQueue.OutletButtonRecord)
            {
                var info = (FeedbackQueue.OutletButtonRecord)record;
                if (_wiring == null)
                {
                    _wiring = new WiringState(info.node, info.outlet);
                }
                else
                {
                    // Currently in wiring: try to make a link.
                    info.node.TryLinkTo(info.outlet, _wiring.node, _wiring.inlet);
                    _wiring = null;
                }
            }

            // Force to end wiring.
            //_wiring = null;
        }
示例#3
0
        // Process feedback from the leaf UI elemets.
        void ProcessUIFeedback(FeedbackQueue.RecordBase record)
        {
            // Delete request
            if (record is FeedbackQueue.DeleteNodeRecord)
            {
                var removeNode = ((FeedbackQueue.DeleteNodeRecord)record).node;

                // Remove related links.
                foreach (var node in _patch.nodeList)
                {
                    node.RemoveLinksTo(removeNode, _patch);
                }

                // Remove the node.
                removeNode.RemoveFromPatch(_patch);

                // Reset the editor state.
                ResetState();
            }

            // Inlet button pressed
            if (record is FeedbackQueue.InletButtonRecord)
            {
                var info = (FeedbackQueue.InletButtonRecord)record;
                if (_wiring == null)
                {
                    // Not in wiring: show the context menu.
                    ShowNodeButtonMenu(info.node, info.inlet, null);
                }
                else
                {
                    // Currently in wiring: try to make a link.
                    _wiring.node.TryLinkTo(_wiring.outlet, info.node, info.inlet);
                }
            }

            // Outlet button pressed
            if (record is FeedbackQueue.OutletButtonRecord)
            {
                var info = (FeedbackQueue.OutletButtonRecord)record;
                if (_wiring == null)
                {
                    // Not in wiring: show the context menu.
                    ShowNodeButtonMenu(info.node, null, info.outlet);
                }
                else
                {
                    // Currently in wiring: try to make a link.
                    info.node.TryLinkTo(info.outlet, _wiring.node, _wiring.inlet);
                }
            }

            // Force to end wiring.
            _wiring = null;
        }
        protected override void DrawGUI()
        {
            EventHandler();

            // Menu
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            _nodeFactory.CreateNodeMenuGUI(_patch);
            GUILayout.Space(100);
            var patchIndex    = _patchManager.GetIndexOf(_patch);
            var newPatchIndex = EditorGUILayout.Popup(
                patchIndex, _patchManager.MakeNameList(),
                EditorStyles.toolbarDropDown);

            GUILayout.FlexibleSpace();
            //GUILayout.Space(100);
            //EditorGUIUtility.labelWidth = 50;
            //_zoom = EditorGUILayout.Slider("Scale", _zoom, 0.5f, 1.5f);
            //EditorGUIUtility.labelWidth = 0;

            EditorGUILayout.EndHorizontal();



            // Main view
            EditorGUILayout.BeginVertical();
            DrawMainViewGUI();
            EditorGUILayout.EndVertical();

            // Re-initialize the editor if the patch selection was changed.
            if (patchIndex != newPatchIndex)
            {
                _patch = _patchManager.RetrieveAt(newPatchIndex);
                _patchManager.Select(_patch);
                ResetPosition();
                ResetSelection();
                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();
                }
            }
        }
 // Go into the wiring state.
 void BeginWiring(object data)
 {
     _wiring = (WiringState)data;
 }
        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();
                }
            }
        }
示例#7
0
        // Process feedback from the leaf UI elemets.
        void ProcessUIFeedback(FeedbackQueue.RecordBase record)
        {
            // Delete request
            if (record is FeedbackQueue.DeleteNodeRecord)
            {
                var removeNode = ((FeedbackQueue.DeleteNodeRecord)record).node;

                // Remove related links.
                foreach (var node in _patch.nodeList)
                    node.RemoveLinksTo(removeNode, _patch);

                // Remove the node.
                removeNode.RemoveFromPatch(_patch);

                // Rescan the patch and repaint.
                _patch.Rescan();
                Repaint();
            }

            // Inlet button pressed
            if (record is FeedbackQueue.InletButtonRecord)
            {
                var info = (FeedbackQueue.InletButtonRecord)record;
                if (_wiring == null)
                    // Not in wiring: show the context menu.
                    ShowNodeButtonMenu(info.node, info.inlet, null);
                else
                    // Currently in wiring: try to make a link.
                    _wiring.node.TryLinkTo(_wiring.outlet, info.node, info.inlet);
            }

            // Outlet button pressed
            if (record is FeedbackQueue.OutletButtonRecord)
            {
                var info = (FeedbackQueue.OutletButtonRecord)record;
                if (_wiring == null)
                    // Not in wiring: show the context menu.
                    ShowNodeButtonMenu(info.node, null, info.outlet);
                else
                    // Currently in wiring: try to make a link.
                    info.node.TryLinkTo(info.outlet, _wiring.node, _wiring.inlet);
            }

            // Force to end wiring.
            _wiring = null;
        }
示例#8
0
 // Go into the wiring state.
 void BeginWiring(object data)
 {
     _wiring = (WiringState)data;
 }
示例#9
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();
                }
            }
        }