CheckNodesValidity() public method

public CheckNodesValidity ( ) : bool
return bool
Exemplo n.º 1
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();
                }
            }
        }
Exemplo n.º 2
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();
        }