Esempio n. 1
0
            internal NodeCanvas AddNode(NodeCanvas nodecanvas)
            {
                if (this.runners.Count == 0)
                {
                    //init node runtime
                    ConnectionPortStyles.FetchConnectionPortStyles();
                    NodeTypes.FetchNodeTypes();
                    NodeCanvasManager.FetchCanvasTypes();
                    ConnectionPortManager.FetchNodeConnectionDeclarations();
                    ImportExportManager.FetchIOFormats();

                    // Setup Callback system
                    NodeEditorCallbacks.SetupReceivers();
                    NodeEditorCallbacks.IssueOnEditorStartUp();
                }

                if (nodecanvas == null)
                {
                    return(null);
                }

                NodeCanvas copycanvas = NodeEditorSaveManager.CreateWorkingCopy(nodecanvas, true);

                //push copy to runners
                runners.Add(copycanvas);

                Restart(copycanvas);
                return(copycanvas);
            }
Esempio n. 2
0
    public static void InitCanvases()
    {
        interactionOverrides = new Dictionary <string, Stack <UnityAction> >();
        traversers           = new List <DialogueTraverser>();
        NodeCanvasManager.FetchCanvasTypes();
        NodeTypes.FetchNodeTypes();
        ConnectionPortManager.FetchNodeConnectionDeclarations();

        if (Instance)
        {
            Instance.ClearCanvases();
        }

        var XMLImport = new XMLImportExport();

        if (Entity.OnEntitySpawn != null)
        {
            Entity.OnEntitySpawn += startDialogueGraph;
        }
        else
        {
            Entity.OnEntitySpawn = startDialogueGraph;
        }

        OnDialogueCancel = null;
        OnDialogueEnd    = null;
        StartDialogueNode.dialogueCanvasNode = null;
        StartDialogueNode.missionCanvasNode  = null;
        initialized = true;
    }
Esempio n. 3
0
    public static void InitCanvases()
    {
        interactionOverrides = new Dictionary <string, Stack <UnityAction> >();
        traversers           = new List <DialogueTraverser>();
        NodeCanvasManager.FetchCanvasTypes();
        NodeTypes.FetchNodeTypes();
        ConnectionPortManager.FetchNodeConnectionDeclarations();

        if (Instance)
        {
            Instance.ClearCanvases();
        }

        var XMLImport = new XMLImportExport();

        for (int i = 0; i < dialogueCanvasPaths.Count; i++)
        {
            string finalPath = System.IO.Path.Combine(Application.streamingAssetsPath, dialogueCanvasPaths[i]);
            //Debug.Log("Dialogue Canvas path [" + i + "] = " + finalPath);
            var canvas = XMLImport.Import(finalPath) as DialogueCanvas;
            //Debug.Log(canvas);
            if (canvas != null)
            {
                traversers.Add(new DialogueTraverser(canvas));
            }
        }

        initialized = true;
    }
Esempio n. 4
0
        public void DrawToolbarGUI(Rect rect)
        {
            rect.height = toolbarHeight;
            GUILayout.BeginArea(rect, NodeEditorGUI.toolbar);
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("File", NodeEditorGUI.toolbarDropdown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "New Canvas/");
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Load Canvas"), false, LoadCanvas);
                menu.AddItem(new GUIContent("Reload Canvas"), false, ReloadCanvas);
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
                menu.ShowAsContext();
            }

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();
            //重定向到数据资产按钮
            EditorGUILayoutExtension.LinkFileLabelField("Click To go to asset Path", this.canvasCache.openedCanvasPath);
            GUILayout.Label(this.canvasCache.typeData.DisplayString, NodeEditorGUI.toolbarLabel);

            NodeEditor.curNodeCanvas.DrawToolbar();

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
 private void BuildResources(NodeItem root)
 {
     foreach (var nodeID in NodeTypes.GetCompatibleNodes(null))
     {
         if (NodeCanvasManager.CheckCanvasCompability(nodeID, NodeEditor.curNodeCanvas.GetType()))
         {
             NodeTypeData nodeTypeData = NodeTypes.GetNodeData(nodeID);
             BuildSingleCategory(root, NodeTypes.GetNodeData(nodeID).adress, nodeTypeData.typeID);
         }
     }
 }
Esempio n. 6
0
    void initCanvases(bool forceReInit)
    {
        if (initialized && !forceReInit)
        {
            return;
        }
        traversers       = new List <MissionTraverser>();
        sectorTraversers = new List <SectorTraverser>();
        NodeCanvasManager.FetchCanvasTypes();
        NodeTypes.FetchNodeTypes();
        ConnectionPortManager.FetchNodeConnectionDeclarations();

        if (Instance)
        {
            Instance.ClearCanvases(true);
        }


        var XMLImport = new XMLImportExport();

        for (int i = 0; i < questCanvasPaths.Count; i++)
        {
            string finalPath = System.IO.Path.Combine(Application.streamingAssetsPath, questCanvasPaths[i]);

            if (finalPath.Contains(".taskdata"))
            {
                var canvas = XMLImport.Import(finalPath) as QuestCanvas;

                if (canvas != null)
                {
                    traversers.Add(new MissionTraverser(canvas));
                }
            }
            else if (finalPath.Contains(".sectordata"))
            {
                var canvas = XMLImport.Import(finalPath) as SectorCanvas;

                if (canvas != null)
                {
                    sectorTraversers.Add(new SectorTraverser(canvas));
                }
            }
        }

        // reset all static condition variables
        SectorLimiterNode.LimitedSector      = "";
        Entity.OnEntityDeath                 = null;
        UsePartCondition.OnPlayerReconstruct = new UnityEvent();
        WinBattleCondition.OnBattleWin       = null;

        initialized = true;
    }
        public void DrawToolbarGUI(Rect rect)
        {
            rect.height = toolbarHeight;
            GUILayout.BeginArea(rect, NodeEditorGUI.toolbar);
            GUILayout.BeginHorizontal();
            float curToolbarHeight = 0;


            if (GUILayout.Button("File", NodeEditorGUI.toolbarDropdown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu(!Application.isPlaying);

                // New Canvas filled with canvas types
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "新建画布/");
                // Load / Save
#if UNITY_EDITOR
                menu.AddItem(new GUIContent("重置画布"), false, ReloadCanvas);
                menu.AddSeparator("");
                if (canvasCache.nodeCanvas.allowSceneSaveOnly)
                {
                    menu.AddDisabledItem(new GUIContent("Save Canvas"));
                    menu.AddDisabledItem(new GUIContent("Save Canvas As"));
                }
                else
                {
                    menu.AddItem(new GUIContent("保存画布"), false, SaveCanvas);
                    menu.AddItem(new GUIContent("另存画布"), false, SaveCanvasAs);
                }
                menu.AddSeparator("");
#endif
                menu.AddItem(new GUIContent("导入数据[未完成!]"), false, Import);
                menu.AddItem(new GUIContent("导出数据[未完成!]"), false, Export);

                // Show dropdown
                menu.Show(new Vector2(5, toolbarHeight));
            }
            curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);

            GUILayout.Space(10);
            string fileName = Path.GetFileNameWithoutExtension(canvasCache.nodeCanvas.savePath);
            GUILayout.Button(new GUIContent(fileName, canvasCache.nodeCanvas.savePath), NodeEditorGUI.toolbarArrow);
            curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);

            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            if (Event.current.type == EventType.Repaint)
            {
                toolbarHeight = curToolbarHeight;
            }
        }
Esempio n. 8
0
        public void DrawToolbarGUI()
        {
            GUILayout.BeginHorizontal(GUI.skin.GetStyle("toolbar"));

            if (GUILayout.Button("File", GUI.skin.GetStyle("toolbarDropdown"), GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu(NodeEditorGUI.useUnityEditorToolbar && !Application.isPlaying);

                // New Canvas filled with canvas types
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "New Canvas/");
                menu.AddSeparator("");

                // Load / Save
#if UNITY_EDITOR
                menu.AddItem(new GUIContent("Load Canvas"), false, LoadCanvas);
                menu.AddItem(new GUIContent("Reload Canvas"), false, ReloadCanvas);
                if (canvasCache.nodeCanvas.allowSceneSaveOnly)
                {
                    menu.AddDisabledItem(new GUIContent("Save Canvas"));
                    menu.AddDisabledItem(new GUIContent("Save Canvas As"));
                }
                else
                {
                    menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                    menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
                }
                menu.AddSeparator("");
                // Scene Saving
                string[] sceneSaves = NodeEditorSaveManager.GetSceneSaves();
                if (sceneSaves.Length <= 0)                 // Display disabled item
                {
                    menu.AddItem(new GUIContent("Load Canvas from Scene"), false, null);
                }
                else
                {
                    foreach (string sceneSave in sceneSaves)                  // Display scene saves to load
                    {
                        menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave);
                    }
                }
                menu.AddItem(new GUIContent("Save Canvas to Scene"), false, SaveSceneCanvasCallback);
                menu.Show(new Vector2(3, toolbarHeight + 3));
#endif

                // Import / Export filled with import/export types
                ImportExportManager.FillImportFormatMenu(ref menu, ImportCanvasCallback, "Import/");
                if (canvasCache.nodeCanvas.allowSceneSaveOnly)
                {
                    menu.AddDisabledItem(new GUIContent("Export"));
                }
                else
                {
                    ImportExportManager.FillExportFormatMenu(ref menu, ExportCanvasCallback, "Export/");
                }
                menu.AddSeparator("");
                // Show dropdown
                menu.Show(new Vector2(3, toolbarHeight + 3));
            }

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            GUILayout.Label(new GUIContent(canvasCache.nodeCanvas.saveName,
                                           "Save Type: " + (canvasCache.nodeCanvas.livesInScene ? "Scene" : "Asset") + "\n" +
                                           "Save Path: " + canvasCache.nodeCanvas.savePath), GUI.skin.GetStyle("toolbarLabel"));
            GUILayout.Label(new GUIContent(canvasCache.typeData.DisplayString, "Canvas Type: " + canvasCache.typeData.DisplayString), GUI.skin.GetStyle("toolbarLabel"));


            GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1);

            /*if (GUILayout.Button("Reinit", GUI.skin.GetStyle("toolbarButton"), GUILayout.Width(100)))
             * {
             *      NodeEditor.ReInit(true);
             *      NodeEditorGUI.CreateDefaultSkin();
             *      canvasCache.nodeCanvas.Validate();
             * }*/
            if (Application.isPlaying)
            {
                GUILayout.Space(5);
                if (GUILayout.Button("Quit", GUI.skin.GetStyle("toolbarButton"), GUILayout.Width(100)))
                {
                    Application.Quit();
                }
            }
            GUI.backgroundColor = Color.white;

            GUILayout.EndHorizontal();
            if (Event.current.type == EventType.Repaint)
            {
                toolbarHeight = GUILayoutUtility.GetLastRect().yMax;
            }
        }
Esempio n. 9
0
        private void DrawSideWindow()
        {
            GUILayout.Label(new GUIContent("Node Editor (" + canvasCache.nodeCanvas.name + ")", "Opened Canvas path: " + canvasCache.openedCanvasPath), NodeEditorGUI.nodeLabelBold);

            EditorGUILayout.ObjectField("Loaded Canvas", canvasCache.nodeCanvas, typeof(NodeCanvas), false);
            EditorGUILayout.ObjectField("Loaded State", canvasCache.editorState, typeof(NodeEditorState), false);

            if (GUILayout.Button(new GUIContent("New Canvas", "Loads an Specified Empty CanvasType")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, canvasCache.NewNodeCanvas);
                menu.Show(createCanvasUIPos.position, createCanvasUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder")))
            {
                string path = EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", NodeEditor.editorPath + "Resources/Saves/");
                if (!string.IsNullOrEmpty(path))
                {
                    canvasCache.SaveNodeCanvas(path);
                }
            }

            if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder")))
            {
                string path = EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Resources/Saves/", "asset");
                if (!path.Contains(Application.dataPath))
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        ShowNotification(new GUIContent("You should select an asset inside your project folder!"));
                    }
                }
                else
                {
                    canvasCache.LoadNodeCanvas(path);
                }
            }

            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(new GUIContent("Save to Scene", "Saves the Canvas to the Scene"), GUILayout.ExpandWidth(false)))
            {
                canvasCache.SaveSceneNodeCanvas(sceneCanvasName);
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave);
                }
                menu.Show(loadSceneUIPos.position, loadSceneUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                loadSceneUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually.")))
            {
                NodeEditor.RecalculateAll(canvasCache.nodeCanvas);
            }

            if (GUILayout.Button("Force Re-Init"))
            {
                NodeEditor.ReInit(true);
            }

            NodeEditorGUI.knobSize       = EditorGUILayout.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20);
            canvasCache.editorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), canvasCache.editorState.zoom, 0.6f, 2);

            if (canvasCache.editorState.selectedNode != null && Event.current.type != EventType.Ignore)
            {
                canvasCache.editorState.selectedNode.DrawNodePropertyEditor();
            }
        }
        public void DrawToolbarGUI(Rect rect)
        {
            rect.height = toolbarHeight;
            GUILayout.BeginArea(rect, NodeEditorGUI.toolbar);
            GUILayout.BeginHorizontal();
            float curToolbarHeight = 0;

            if (GUILayout.Button("File", NodeEditorGUI.toolbarDropdown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu(!Application.isPlaying);

                // New Canvas filled with canvas types
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "New Canvas/");
                menu.AddSeparator("");

                // Load / Save
#if UNITY_EDITOR
                menu.AddItem(new GUIContent("Load Canvas"), false, LoadCanvas);
                menu.AddItem(new GUIContent("Reload Canvas"), false, ReloadCanvas);
                menu.AddSeparator("");
                if (canvasCache.nodeCanvas.allowSceneSaveOnly)
                {
                    menu.AddDisabledItem(new GUIContent("Save Canvas"));
                    menu.AddDisabledItem(new GUIContent("Save Canvas As"));
                }
                else
                {
                    menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                    menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
                }
                menu.AddSeparator("");
#endif

                // Import / Export filled with import/export types
                ImportExportManager.FillImportFormatMenu(ref menu, ImportCanvasCallback, "Import/");
                if (canvasCache.nodeCanvas.allowSceneSaveOnly)
                {
                    menu.AddDisabledItem(new GUIContent("Export"));
                }
                else
                {
                    ImportExportManager.FillExportFormatMenu(ref menu, ExportCanvasCallback, "Export/");
                }
                menu.AddSeparator("");

                // Scene Saving
                string[] sceneSaves = NodeEditorSaveManager.GetSceneSaves();
                if (sceneSaves.Length <= 0)                 // Display disabled item
                {
                    menu.AddItem(new GUIContent("Load Canvas from Scene"), false, null);
                }
                else
                {
                    foreach (string sceneSave in sceneSaves)                  // Display scene saves to load
                    {
                        menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave);
                    }
                }
                menu.AddItem(new GUIContent("Save Canvas to Scene"), false, SaveSceneCanvasCallback);

                // Show dropdown
                menu.Show(new Vector2(5, toolbarHeight));
            }
            curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            GUILayout.Label(new GUIContent("" + canvasCache.nodeCanvas.saveName + " (" + (canvasCache.nodeCanvas.livesInScene ? "Scene Save" : "Asset Save") + ")",
                                           "Opened Canvas path: " + canvasCache.nodeCanvas.savePath), NodeEditorGUI.toolbarLabel);
            GUILayout.Label("Type: " + canvasCache.typeData.DisplayString, NodeEditorGUI.toolbarLabel);
            curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);

            GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1);
            if (GUILayout.Button("Force Re-init", NodeEditorGUI.toolbarButton, GUILayout.Width(100)))
            {
                NodeEditor.ReInit(true);
                canvasCache.nodeCanvas.Validate();
            }
#if !UNITY_EDITOR
            GUILayout.Space(5);
            if (GUILayout.Button("Quit", NodeEditorGUI.toolbarButton, GUILayout.Width(100)))
            {
                Application.Quit();
            }
#endif
            curToolbarHeight    = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);
            GUI.backgroundColor = Color.white;

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            if (Event.current.type == EventType.Repaint)
            {
                toolbarHeight = curToolbarHeight;
            }
        }
        public void SideGUI()
        {
            GUILayout.Label(new GUIContent("" + cache.nodeCanvas.saveName + " (" + (cache.nodeCanvas.livesInScene? "Scene Save" : "Asset Save") + ")", "Opened Canvas path: " + cache.nodeCanvas.savePath), NodeEditorGUI.nodeLabelBold);
            GUILayout.Label("Type: " + cache.typeData.DisplayString + "/" + cache.nodeCanvas.GetType().Name + "");



            if (GUILayout.Button(new GUIContent("New Canvas", "Loads an Specified Empty CanvasType")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, cache.NewNodeCanvas);
                menu.Show(createCanvasUIPos.position, createCanvasUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }
            if (cache.nodeCanvas.GetType() == typeof(NodeCanvas) && GUILayout.Button(new GUIContent("Convert Canvas", "Converts the current canvas to a new type.")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, cache.ConvertCanvasType);
                menu.Show(convertCanvasUIPos.position, convertCanvasUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                convertCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            if (GUILayout.Button(new GUIContent("Save Canvas", "Save the Canvas to the load location")))
            {
                string path = cache.nodeCanvas.savePath;
                if (!string.IsNullOrEmpty(path))
                {
                    if (path.StartsWith("SCENE/"))
                    {
                        cache.SaveSceneNodeCanvas(path.Substring(6));
                    }
                    else
                    {
                        cache.SaveNodeCanvas(path);
                    }
                }
            }



                #if UNITY_EDITOR
            GUILayout.Label("Asset Saving", NodeEditorGUI.nodeLabel);

            if (GUILayout.Button(new GUIContent("Save Canvas As", "Save the canvas as an asset")))
            {
                string panelPath = NodeEditor.editorPath + "Resources/Saves/";
                if (cache.nodeCanvas != null && !string.IsNullOrEmpty(cache.nodeCanvas.savePath))
                {
                    panelPath = cache.nodeCanvas.savePath;
                }
                string path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", panelPath);
                if (!string.IsNullOrEmpty(path))
                {
                    cache.SaveNodeCanvas(path);
                }
            }

            if (GUILayout.Button(new GUIContent("Load Canvas", "Load the Canvas from an asset")))
            {
                string panelPath = NodeEditor.editorPath + "Resources/Saves/";
                if (cache.nodeCanvas != null && !string.IsNullOrEmpty(cache.nodeCanvas.savePath))
                {
                    panelPath = cache.nodeCanvas.savePath;
                }
                string path = UnityEditor.EditorUtility.OpenFilePanel("Load Node Canvas", panelPath, "asset");
                if (!path.Contains(Application.dataPath))
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        Debug.LogWarning(new GUIContent("You should select an asset inside your project folder!"));
                    }
                }
                else
                {
                    cache.LoadNodeCanvas(path);
                }
                if (cache.nodeCanvas.GetType() == typeof(NodeCanvas))
                {
                    Debug.LogWarning(new GUIContent("The Canvas has no specific type. Please use the convert button to assign a type and re-save the canvas!"));
                }
            }
                #endif

            GUILayout.Label("Scene Saving", NodeEditorGUI.nodeLabel);

            GUILayout.BeginHorizontal();
            sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(new GUIContent("Save to Scene", "Save the canvas to the Scene"), GUILayout.ExpandWidth(false)))
            {
                cache.SaveSceneNodeCanvas(sceneCanvasName);
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button(new GUIContent("Load from Scene", "Load the canvas from the Scene")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave);
                }
                menu.Show(loadSceneUIPos.position, loadSceneUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                loadSceneUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }



            GUILayout.Label("Utility/Debug", NodeEditorGUI.nodeLabel);

            if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually.")))
            {
                cache.nodeCanvas.TraverseAll();
            }

            if (GUILayout.Button("Force Re-Init"))
            {
                NodeEditor.ReInit(true);
            }

            NodeEditorGUI.knobSize = RTEditorGUI.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20);
            //cache.editorState.zoom = EditorGUILayout.Slider (new GUIContent ("Zoom", "Use the Mousewheel. Seriously."), cache.editorState.zoom, 0.6f, 4);
            NodeEditorUserCache.cacheIntervalSec = RTEditorGUI.IntSlider(new GUIContent("Cache Interval (Sec)", "The interval in seconds the canvas is temporarily saved into the cache as a precaution for crashes."), NodeEditorUserCache.cacheIntervalSec, 30, 300);

            screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen");
            GUILayout.Label("FPS: " + FPSCounter.currentFPS);



            if (cache.editorState.selectedNode != null && Event.current.type != EventType.Ignore)
            {
                cache.editorState.selectedNode.DrawNodePropertyEditor();
            }
        }
Esempio n. 12
0
        public override CanvasData ImportData(params object[] args)
        {
            if (args == null || args.Length != 1 || args[0].GetType() != typeof(string))
            {
                throw new ArgumentException("Location Arguments");
            }
            string path = (string)args[0];

            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                XmlDocument data = new XmlDocument();
                data.Load(fs);

                // CANVAS

                string     canvasName = Path.GetFileNameWithoutExtension(path);
                XmlElement xmlCanvas  = (XmlElement)data.SelectSingleNode("//NodeCanvas");
                Type       canvasType = NodeCanvasManager.GetCanvasTypeData(xmlCanvas.GetAttribute("type")).CanvasType;
                if (canvasType == null)
                {
                    throw new XmlException("Could not find NodeCanvas of type '" + xmlCanvas.GetAttribute("type") + "'!");
                }
                CanvasData canvasData            = new CanvasData(canvasType, canvasName);
                Dictionary <int, PortData> ports = new Dictionary <int, PortData>();

                // OBJECTS

                IEnumerable <XmlElement> xmlObjects = xmlCanvas.SelectNodes("Objects/Object").OfType <XmlElement>();
                foreach (XmlElement xmlObject in xmlObjects)
                {
                    int        refID    = GetIntegerAttribute(xmlObject, "refID");
                    string     typeName = xmlObject.GetAttribute("type");
                    Type       type     = Type.GetType(typeName, true);
                    object     obj      = DeserializeObjectFromXML(xmlObject, type);
                    ObjectData objData  = new ObjectData(refID, obj);
                    canvasData.objects.Add(refID, objData);
                }

                // NODES

                IEnumerable <XmlElement> xmlNodes = xmlCanvas.SelectNodes("Nodes/Node").OfType <XmlElement>();
                foreach (XmlElement xmlNode in xmlNodes)
                {
                    string  name    = xmlNode.GetAttribute("name");
                    int     nodeID  = GetIntegerAttribute(xmlNode, "ID");
                    string  typeID  = xmlNode.GetAttribute("type");
                    Vector2 nodePos = GetVectorAttribute(xmlNode, "pos");
                    // Record
                    NodeData node = new NodeData(name, typeID, nodeID, nodePos);
                    canvasData.nodes.Add(nodeID, node);

                    // NODE PORTS

                    IEnumerable <XmlElement> xmlConnectionPorts = xmlNode.SelectNodes("Port").OfType <XmlElement>();
                    foreach (XmlElement xmlPort in xmlConnectionPorts)
                    {
                        int    portID   = GetIntegerAttribute(xmlPort, "ID");
                        string portName = xmlPort.GetAttribute("name");
                        if (string.IsNullOrEmpty(portName))                         // Fallback to old save
                        {
                            portName = xmlPort.GetAttribute("varName");
                        }
                        bool     dynamic = GetBooleanAttribute(xmlPort, "dynamic", false);
                        PortData portData;
                        if (!dynamic)                         // Record static port
                        {
                            portData = new PortData(node, portName, portID);
                        }
                        else
                        {                         // Deserialize dynamic port
                            string typeName = xmlPort.GetAttribute("type");
                            Type   portType = Type.GetType(typeName, true);
                            if (portType != typeof(ConnectionPort) && !portType.IsSubclassOf(typeof(ConnectionPort)))
                            {
                                continue;                                 // Invalid type stored
                            }
                            ConnectionPort port = (ConnectionPort)ScriptableObject.CreateInstance(portType);
                            port.name = portName;
                            foreach (XmlElement portVar in xmlPort.ChildNodes.OfType <XmlElement>())
                            {
                                DeserializeFieldFromXML(portVar, port);
                            }
                            portData = new PortData(node, port, portID);
                        }
                        node.connectionPorts.Add(portData);
                        ports.Add(portID, portData);
                    }

                    // NODE VARIABLES

                    foreach (XmlElement variable in xmlNode.ChildNodes.OfType <XmlElement>())
                    {                     // Deserialize all value-type variables
                        if (variable.Name != "Variable" && variable.Name != "Port")
                        {
                            string       varName  = variable.GetAttribute("name");
                            object       varValue = DeserializeFieldFromXML(variable, node.type, null);
                            VariableData varData  = new VariableData(varName);
                            varData.value = varValue;
                            node.variables.Add(varData);
                        }
                    }

                    IEnumerable <XmlElement> xmlVariables = xmlNode.SelectNodes("Variable").OfType <XmlElement>();
                    foreach (XmlElement xmlVariable in xmlVariables)
                    {                     // Deserialize all reference-type variables (and also value type variables in old save files)
                        string       varName = xmlVariable.GetAttribute("name");
                        VariableData varData = new VariableData(varName);
                        if (xmlVariable.HasAttribute("refID"))
                        {                         // Read reference-type variables from objects
                            int        refID = GetIntegerAttribute(xmlVariable, "refID");
                            ObjectData objData;
                            if (canvasData.objects.TryGetValue(refID, out objData))
                            {
                                varData.refObject = objData;
                            }
                        }
                        else
                        {                         // Read value-type variable (old save file only) TODO: Remove
                            string typeName = xmlVariable.GetAttribute("type");
                            Type   type     = Type.GetType(typeName, true);
                            varData.value = DeserializeObjectFromXML(xmlVariable, type);
                        }
                        node.variables.Add(varData);
                    }
                }

                // CONNECTIONS

                IEnumerable <XmlElement> xmlConnections = xmlCanvas.SelectNodes("Connections/Connection").OfType <XmlElement>();
                foreach (XmlElement xmlConnection in xmlConnections)
                {
                    int      port1ID = GetIntegerAttribute(xmlConnection, "port1ID");
                    int      port2ID = GetIntegerAttribute(xmlConnection, "port2ID");
                    PortData port1, port2;
                    if (ports.TryGetValue(port1ID, out port1) && ports.TryGetValue(port2ID, out port2))
                    {
                        canvasData.RecordConnection(port1, port2);
                    }
                }

                // GROUPS

                IEnumerable <XmlElement> xmlGroups = xmlCanvas.SelectNodes("Groups/Group").OfType <XmlElement>();
                foreach (XmlElement xmlGroup in xmlGroups)
                {
                    string name  = xmlGroup.GetAttribute("name");
                    Rect   rect  = GetRectAttribute(xmlGroup, "rect");
                    Color  color = GetColorAttribute(xmlGroup, "color");
                    canvasData.groups.Add(new GroupData(name, rect, color));
                }

                // EDITOR STATES

                IEnumerable <XmlElement> xmlEditorStates = xmlCanvas.SelectNodes("EditorStates/EditorState").OfType <XmlElement>();
                List <EditorStateData>   editorStates    = new List <EditorStateData>();
                foreach (XmlElement xmlEditorState in xmlEditorStates)
                {
                    Vector2 pan = GetVectorAttribute(xmlEditorState, "pan");
                    float   zoom;
                    if (!float.TryParse(xmlEditorState.GetAttribute("zoom"), out zoom))
                    {
                        zoom = 1;
                    }
                    // Selected Node
                    NodeData selectedNode = null;
                    int      selectedNodeID;
                    if (int.TryParse(xmlEditorState.GetAttribute("selected"), out selectedNodeID))
                    {
                        selectedNode = canvasData.FindNode(selectedNodeID);
                    }
                    // Create state
                    editorStates.Add(new EditorStateData(selectedNode, pan, zoom));
                }
                canvasData.editorStates = editorStates.ToArray();

                return(canvasData);
            }
        }
Esempio n. 13
0
        private void DrawSideWindow()
        {
            GUILayout.Label("Shadero Sprite v1.9.3", NodeEditorGUI.nodeLabelBold);

            if (NodeEditor._Shadero_Material == null)
            {
                Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_material.jpg");
                GUI.DrawTexture(new Rect(5, 30, 196, 196), preview);
            }
            else
            {
                if (!NodeEditor.NoBuildShader)
                {
                    Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_buildshader.jpg");
                    GUI.DrawTexture(new Rect(5, 30, 196, 196), preview);
                }
                else
                {
                    if (!NodeEditor.FlagIsSaved)
                    {
                        Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_shader.jpg");
                        GUI.DrawTexture(new Rect(5, 30, 196, 196), preview);
                    }
                    else
                    {
                        if (!NodeEditor.RGBAonBuildShader)
                        {
                            Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_no_rgba_buildshader.jpg");
                            GUI.DrawTexture(new Rect(5, 30, 196, 196), preview);
                        }
                        else
                        {
                            NodeEditor._Shadero_Material.shader = Shader.Find("Shadero Customs/" + Node.ShaderNameX);
                            Texture2D preview = ResourceManager.LoadTexture("Textures/previews/Preview_Shader.jpg");
                            GUI.DrawTexture(new Rect(5, 30, 196, 196), preview);

                            Texture tex = NodeEditor._Shadero_Material.mainTexture;
                            if (tex == null)
                            {
                                tex = ResourceManager.LoadTexture("Textures/previews/Preview_Shader.jpg");
                            }
                            float x = Event.current.mousePosition.x - 8;
                            float y = Event.current.mousePosition.y - 33;
                            x = x / 190;
                            y = y / 190;

                            if ((x > 0 && x < 1) && (y > 0 && y < 1))
                            {
                                EditorGUI.DrawPreviewTexture(new Rect(8, 33, 190, 190), tex, NodeEditor._Shadero_Material);

                                if (FullScreenSet > 3)
                                {
                                    EditorGUI.DrawPreviewTexture(new Rect(-(Screen.width / 2) - Screen.height / 4, 10, Screen.height, Screen.height), tex, NodeEditor._Shadero_Material);
                                }

                                FullScreenSet += Time.deltaTime;
                            }
                            else
                            {
                                FullScreenSet = 0;
                                EditorGUI.DrawPreviewTexture(new Rect(8, 33, 190, 190), tex, NodeEditor._Shadero_Material);
                            }
                        }
                    }
                }
            }
            GUILayout.Space(200);

            GUIStyle g = new GUIStyle();

            if (NodeEditor._Shadero_Material != null)
            {
                int ms = g.fontSize;
                g.fontSize         = 10;
                g.alignment        = TextAnchor.UpperRight;
                g.normal.textColor = Color.white;
                GUILayout.Label("*Preview Material", g);
                g.fontSize = ms;
            }
            else
            {
                GUILayout.Label("Preview Material");
            }
            PreviewLiveAnimation = GUILayout.Toggle(PreviewLiveAnimation, "Active live animation");
            if (PreviewLiveAnimation)
            {
                NodeEditor.RepaintClients();
            }

            g                  = new GUIStyle();
            g.fontSize         = 12;
            g.normal.textColor = Color.white;

            UseOwnMaterial = GUILayout.Toggle(UseOwnMaterial, "Use your own Material");

            if (!UseOwnMaterial)
            {
                NodeEditor._Shadero_Material = AssetDatabase.LoadAssetAtPath("Assets/ShaderoSprite/Plugins/EditorResources/Preview/PreviewMaterial.mat", typeof(Material)) as Material;
            }
            else
            {
                GUILayout.Space(25);
                NodeEditor._Shadero_Material = (Material)EditorGUI.ObjectField(new Rect(5, 285, 200, 18), NodeEditor._Shadero_Material, typeof(Material), true);
                if (NodeEditor._Shadero_Material == null)
                {
                    UseOwnMaterial = false;
                }
            }

            if (MaterialChange == null)
            {
                MaterialChange = AssetDatabase.GetAssetPath(NodeEditor._Shadero_Material);
            }
            if (MaterialChange != AssetDatabase.GetAssetPath(NodeEditor._Shadero_Material))
            {
                NodeEditor.FlagIsMaterialChanged = true;
                NodeEditor.ShaderToNull          = true;
            }
            MaterialChange = AssetDatabase.GetAssetPath(NodeEditor._Shadero_Material);
            GUILayout.Space(10);

            if (NodeEditor.RecalculateFlag)
            {
                NodeEditor.ForceWriteFlag = true;
                NodeEditor.RecalculateAll(canvasCache.nodeCanvas);
                NodeEditor.RecalculateFlag = false;
            }

            if (GUILayout.Button(new GUIContent("New Shader Project", "Loads an Specified Empty Shadero project")))
            {
                _ShaderoShaderEditorFramework.Utilities.GenericMenu menu = new _ShaderoShaderEditorFramework.Utilities.GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, canvasCache.NewNodeCanvas);
                menu.Show(createCanvasUIPos.position, createCanvasUIPos.width);
            }
            if (NodeEditor.NewCanvasWasCalled)
            {
                UseOwnMaterial = false;
                NodeEditor._Shadero_Material  = null;
                NodeEditor.NewCanvasWasCalled = false;
            }

            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Save Shader Project", "Saves the project to a project Save File in the Assets Folder")))
            {
                string path = EditorUtility.SaveFilePanelInProject("Save Shadero Shader Project", "Shadero Shader Project", "asset", "", NodeEditor.editorPath + "Shadero_Projects/");
                if (!string.IsNullOrEmpty(path))
                {
                    canvasCache.SaveNodeCanvas(path);
                    // NodeEditor.FlagIsSavedMaterial = true;
                }
            }

            if (GUILayout.Button(new GUIContent("Load Shader Project", "Loads the project from a project Save File in the Assets Folder")))
            {
                string path = EditorUtility.OpenFilePanel("Load Shadero Shader Project", NodeEditor.editorPath + "Shadero_Projects/", "asset");
                if (!path.Contains(Application.dataPath))
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        ShowNotification(new GUIContent("You should select an asset inside your project folder!"));
                    }
                }
                else
                {
                    UseOwnMaterial = false;
                    canvasCache.LoadNodeCanvas(path);
                }
            }

            GUILayout.Space(6);

            g                  = new GUIStyle();
            g.fontSize         = 12;
            g.alignment        = TextAnchor.LowerLeft;
            g.normal.textColor = Color.white;

            if (!NodeEditor.NoBuildShader)
            {
                GUILayout.Label(" ", g);
                GUILayout.Label("What to do ?", g);
                GUILayout.Label(" ", g);
                GUILayout.Label("- You need to create a ", g);
                GUILayout.Label("  Build Shader \"Node Shader\"", g);
                GUILayout.Label("  , Right Click on the", g);
                GUILayout.Label("  Node Canvas and Select ", g);
                GUILayout.Label("  \"Add Build Shader\".", g);
            }
            else
            {
                GUILayout.Label(" ", g);
                GUILayout.Label("What to do ?", g);
                GUILayout.Label(" ", g);
                GUILayout.Label("-If you want to use your ", g);
                GUILayout.Label("  own material, active ", g);
                GUILayout.Label(" the \"Use your own material\" )", g);
                GUILayout.Label(" button. ", g);
                GUILayout.Label("", g);
                GUILayout.Label("  We recommand you to always ", g);
                GUILayout.Label("  active the \"Active live animation\"", g);
                GUILayout.Label("  for a better experience.", g);
            }

            if (canvasCache.editorState.selectedNode != null && Event.current.type != EventType.Ignore)
            {
                canvasCache.editorState.selectedNode.DrawNodePropertyEditor();
            }
        }
Esempio n. 14
0
    void initCanvases(bool forceReInit)
    {
        if (initialized && !forceReInit)
        {
            return;
        }

        traversers       = new List <MissionTraverser>();
        sectorTraversers = new List <SectorTraverser>();
        NodeCanvasManager.FetchCanvasTypes();
        NodeTypes.FetchNodeTypes();
        ConnectionPortManager.FetchNodeConnectionDeclarations();

        if (Instance)
        {
            Instance.ClearCanvases(true);
        }


        var XMLImport = new XMLImportExport();

        for (int i = 0; i < questCanvasPaths.Count; i++)
        {
            string finalPath = System.IO.Path.Combine(Application.streamingAssetsPath, questCanvasPaths[i]);

            if (finalPath.Contains(".taskdata"))
            {
                if (SaveHandler.instance?.GetSave()?.missions != null)
                {
                    var missionName = $"{System.IO.Path.GetFileNameWithoutExtension(finalPath)}";
                    var mission     = SaveHandler.instance.GetSave().missions.Find(m => m.name == missionName);
                    if (mission != null)
                    {
                        if (mission.status == Mission.MissionStatus.Complete)
                        {
                            continue;
                        }
                        if (mission.prerequisites != null && SaveHandler.instance.GetSave().missions.Exists(m =>
                                                                                                            mission.prerequisites.Contains(m.name) &&
                                                                                                            m.status != Mission.MissionStatus.Complete))
                        {
                            offloadingMissions.Add(missionName, finalPath);
                            continue;
                        }
                    }
                }

                var canvas = XMLImport.Import(finalPath) as QuestCanvas;

                if (canvas != null)
                {
                    traversers.Add(new MissionTraverser(canvas));
                }
            }
        }

        // reset all static condition variables
        SectorLimiterNode.LimitedSector      = "";
        Entity.OnEntityDeath                 = null;
        UsePartCondition.OnPlayerReconstruct = new UnityEvent();
        WinBattleCondition.OnBattleWin       = null;
        WinBattleCondition.OnBattleLose      = null;
        SectorManager.SectorGraphLoad       += startSectorGraph;

        initialized = true;
    }
Esempio n. 15
0
        public void SideGUI()
        {
            screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen");
            GUILayout.Label("FPS: " + FPSCounter.currentFPS);

            GUILayout.Label(new GUIContent("Node Editor (" + cache.nodeCanvas.name + ")"), NodeEditorGUI.nodeLabelBold);

            if (GUILayout.Button(new GUIContent("New Canvas", "Loads an Specified Empty CanvasType")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, cache.NewNodeCanvas);
                menu.Show(createCanvasPos.position, createCanvasPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                createCanvasPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

                #if UNITY_EDITOR
            if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder")))
            {
                string path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", NodeEditor.editorPath + "Resources/Saves/");
                if (!string.IsNullOrEmpty(path))
                {
                    NodeEditorSaveManager.SaveNodeCanvas(path, cache.nodeCanvas, true);
                }
            }

            if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder")))
            {
                string path = UnityEditor.EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Resources/Saves/", "asset");
                if (!path.Contains(Application.dataPath))
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        Debug.LogWarning("You should select an asset inside your project folder!");
                    }
                }
                else
                {
                    path = path.Replace(Application.dataPath, "Assets");
                    cache.LoadNodeCanvas(path);
                }
            }
            GUILayout.Space(6);
                #endif

            GUILayout.BeginHorizontal();
            sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(new GUIContent("Save to Scene", "Saves the Canvas to the Scene"), GUILayout.ExpandWidth(false)))
            {
                cache.SaveSceneNodeCanvas(sceneCanvasName);
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave);
                }
                menu.Show(loadScenePos.position, loadScenePos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                loadScenePos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually.")))
            {
                NodeEditor.RecalculateAll(cache.nodeCanvas);
            }

            if (GUILayout.Button("Force Re-Init"))
            {
                NodeEditor.ReInit(true);
            }

            NodeEditorGUI.knobSize = RTEditorGUI.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20);
            cache.editorState.zoom = RTEditorGUI.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), cache.editorState.zoom, 0.6f, 2);
        }
        public void DrawToolbarGUI(Rect rect)
        {
            rect.height = toolbarHeight;
            GUILayout.BeginArea(rect, NodeEditorGUI.toolbar);
            GUILayout.BeginHorizontal();
            float curToolbarHeight = 0;

            if (GUILayout.Button("File", NodeEditorGUI.toolbarDropdown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu();

                // New Canvas filled with canvas types
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "New Canvas/");
                menu.AddSeparator("");

                // Load / Save
#if UNITY_EDITOR
                menu.AddItem(new GUIContent("Load Canvas"), false, LoadCanvas);
                menu.AddItem(new GUIContent("Reload Canvas"), false, ReloadCanvas);
                menu.AddSeparator("");

                menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);

                // menu.AddSeparator("");
#endif
                menu.Show(new Vector2(5, toolbarHeight));
            }

            curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            GUILayout.Label(new GUIContent(this.canvasCache.openedCanvasPath), NodeEditorGUI.toolbarLabel);
            GUILayout.Label(this.canvasCache.typeData.DisplayString, NodeEditorGUI.toolbarLabel);
            curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);

            GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1);
            if (NodeEditor.curNodeCanvas is NPBehaveCanvas)
            {
                if (GUILayout.Button("DataBase", NodeEditorGUI.toolbarButton, GUILayout.Width(100)))
                {
                    NPBehaveCanvas npBehaveCanvas = this.canvasCache.nodeCanvas as NPBehaveCanvas;
                    UnityEditor.Selection.activeObject = npBehaveCanvas.GetCurrentCanvasDatas();
                }
            }

#if !UNITY_EDITOR
            GUILayout.Space(5);
            if (GUILayout.Button("Quit", NodeEditorGUI.toolbarButton, GUILayout.Width(100)))
            {
                Application.Quit();
            }
#endif
            curToolbarHeight    = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax);
            GUI.backgroundColor = Color.white;

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            if (Event.current.type == EventType.Repaint)
            {
                toolbarHeight = curToolbarHeight;
            }
        }