コード例 #1
0
    void OnGUI()
    {
        if (!IsConstellationSelected())
        {
            StartPanel.Draw(this);
            return;
        }
        else
        {
            try
            {
                TopBarPanel.Draw(this, this, this);
                var constellationName = NodeTabPanel.Draw(ScriptDataService.OpenedScripts.ToArray());
                if (constellationName != null)
                {
                    var selectedGameObjects = Selection.gameObjects;
                    if (Application.isPlaying)
                    {
                        ScriptDataService.CloseCurrentConstellationInstance();
                        Open(ScriptDataService.OpenedScripts.ToArray()[0]);
                        previousSelectedGameObject = selectedGameObjects[0];
                    }
                    Open(constellationName);
                }
                var constellationToRemove = NodeTabPanel.ConstellationToRemove();
                EditorGUILayout.BeginHorizontal();
                if (NodeWindow == null)
                {
                    ParseScript();
                }
                NodeWindow.UpdateSize(position.width - nodeSelectorWidth - splitThickness, position.height - NodeTabPanel.GetHeight());
                NodeWindow.Draw(RequestRepaint, OnEditorEvent, ScriptDataService.GetConstellationEditorConfig(), out nodeWindowSize, out nodeWindowScrollPosition);
                DrawVerticalSplit();
                NodeSelector.Draw(nodeSelectorWidth, position.height, NodeAdded, ScriptDataService.Script.CanChangeType);
                EditorGUILayout.EndHorizontal();
                if (ScriptDataService.CloseOpenedConstellation(constellationToRemove))
                {
                    if (ScriptDataService.OpenedScripts.Count > 0)
                    {
                        Open(ScriptDataService.OpenedScripts[0]);
                    }
                    else
                    {
                        ScriptDataService.Script = null;
                    }
                }
                DrawInstancePannel();
            }
            catch (System.Exception exception)
            {
                UnexpectedError(exception.StackTrace);
            }
        }

        if (requestRepaint)
        {
            Repaint();
        }
    }
コード例 #2
0
    void Update()
    {
        if (Application.isPlaying && IsConstellationSelected())
        {
            if (NodeWindow != null && previousSelectedGameObject != null && ScriptDataService.GetCurrentScript().IsInstance)
            {
                NodeWindow.Update(currentEditableConstellation.GetConstellation(), OnEditorEvent);
            }

            var selectedGameObjects = Selection.gameObjects;
            if (selectedGameObjects.Length == 0 || selectedGameObjects[0] == previousSelectedGameObject || selectedGameObjects[0].activeInHierarchy == false)
            {
                return;
            }
            else if (ScriptDataService.GetCurrentScript().IsInstance)
            {
                ScriptDataService.CloseCurrentConstellationInstance();
                previousSelectedGameObject = selectedGameObjects[0];
                //RequestSetup();
            }

            var selectedConstellation = selectedGameObjects[0].GetComponent <ConstellationEditable>() as ConstellationEditable;
            if (selectedConstellation != null)
            {
                currentEditableConstellation = selectedConstellation;
                previousSelectedGameObject   = selectedGameObjects[0];
                OpenConstellationInstance(selectedConstellation.GetConstellation(), AssetDatabase.GetAssetPath(selectedConstellation.GetConstellationData()));
                if (selectedConstellation.GetConstellation() == null)
                {
                    return;
                }
                selectedConstellation.Initialize();
            }
        }
        else
        {
            previousSelectedGameObject = null;
        }
    }