示例#1
0
 public void ResetCompletely(string saveName)
 {
     saveFiles     = NodeEditorSaveManager.GetSceneSaves();
     this.saveName = saveName;
     for (int i = 0; i < saveFiles.Length; i++)
     {
         if (saveFiles[i] == saveName)
         {
             saveChoice = i;
             break;
         }
     }
     Awake();
     state = InterfaceState.Dirty;
 }
示例#2
0
 public void SideGUI()
 {
     GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")", "The currently opened canvas in the Node Editor"));
     screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen");
     GUILayout.Label("FPS: " + FPSCounter.currentFPS);
     GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")"), NodeEditorGUI.nodeLabelBold);
     if (GUILayout.Button(new GUIContent("New Canvas", "Loads an empty Canvas")))
     {
         NewNodeCanvas();
     }
     GUILayout.Space(6f);
     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)))
     {
         SaveSceneNodeCanvas(sceneCanvasName);
     }
     GUILayout.EndHorizontal();
     if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene")))
     {
         GenericMenu genericMenu = new GenericMenu();
         string[]    sceneSaves  = NodeEditorSaveManager.GetSceneSaves();
         foreach (string text in sceneSaves)
         {
             genericMenu.AddItem(new GUIContent(text), false, LoadSceneCanvasCallback, text);
         }
         genericMenu.Show(loadScenePos, 40f);
     }
     if (Event.current.type == EventType.Repaint)
     {
         Rect lastRect = GUILayoutUtility.GetLastRect();
         loadScenePos = new Vector2(lastRect.x + 2f, lastRect.yMax + 2f);
     }
     GUILayout.Space(6f);
     if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually.")))
     {
         NodeEditor.RecalculateAll(canvas);
     }
     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);
     state.zoom             = RTEditorGUI.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), state.zoom, 0.6f, 2f);
 }
示例#3
0
    public override void OnInspectorGUI()
    {
        var dialogue = target as DialogueInterface;

        if (dialogue == null)
        {
            return;
        }
        if (string.IsNullOrEmpty(dialogue.saveName))
        {
            dialogue.saveFiles = NodeEditorSaveManager.GetSceneSaves();
        }

        if (dialogue.saveFiles.Length == 0)
        {
            return;
        }


        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Nodegraph:");

        var newChoice = EditorGUILayout.Popup(dialogue.saveChoice, dialogue.saveFiles);

        EditorGUILayout.EndHorizontal();
        if (newChoice != dialogue.saveChoice)
        {
            dialogue.saveChoice = newChoice;
            dialogue.saveName   = dialogue.saveFiles[dialogue.saveChoice];
            dialogue.Reset();
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Force Reloading"))
        {
            dialogue.saveName = dialogue.saveFiles[dialogue.saveChoice];
            dialogue.Reset();
        }
        if (GUILayout.Button("Reload saves"))
        {
            dialogue.saveFiles = NodeEditorSaveManager.GetSceneSaves();
        }
        EditorGUILayout.EndHorizontal();
        DrawDefaultInspector();
    }
示例#4
0
    public override void OnInspectorGUI()
    {
        CraftingInterface crafting = target as CraftingInterface;

        if (crafting.saveChoices == null)
        {
            crafting.saveChoices = NodeEditorSaveManager.GetSceneSaves();
        }

        if (crafting.saveChoices.Length == 0)
        {
            return;
        }
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Nodegraph:");
        var newChoice = EditorGUILayout.Popup(crafting.saveChoice, crafting.saveChoices);

        EditorGUILayout.EndHorizontal();
        if (newChoice != crafting.saveChoice)
        {
            crafting.saveChoice = newChoice;
            crafting.saveName   = crafting.saveChoices[crafting.saveChoice];
            crafting.Reset();
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Force Reloading"))
        {
            crafting.Reset();
        }
        if (GUILayout.Button("Reload saves"))
        {
            crafting.saveChoices = NodeEditorSaveManager.GetSceneSaves();
        }
        EditorGUILayout.EndHorizontal();
        DrawDefaultInspector();
    }
示例#5
0
 public void OnEnable()
 {
     RTNE             = (RTNodeEditor)target;
     sceneCanvasNames = NodeEditorSaveManager.GetSceneSaves();
 }
示例#6
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;
            }
        }
        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();
            }
        }
示例#8
0
        public void SideGUI()
        {
            GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")", "The currently opened canvas in the Node Editor"));
            screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen");
            GUILayout.Label("FPS: " + FPSCounter.currentFPS);

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

            if (GUILayout.Button(new GUIContent("New Canvas", "Loads an empty Canvas")))
            {
                NewNodeCanvas();
            }

            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, canvas, 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");
                    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)))
            {
                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);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                loadScenePos = new Vector2(popupPos.x + 2, popupPos.yMax + 2);
            }

            GUILayout.Space(6);

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

            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);
            state.zoom             = RTEditorGUI.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), state.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(!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();
            }
        }
示例#11
0
        protected void DrawToolbarGUI()
        {
            EditorGUILayout.BeginHorizontal("Toolbar");
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f);

            if (GUILayout.Button("File", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                var menu = new GenericMenu();

                foreach (System.Collections.Generic.KeyValuePair <Type, NodeCanvasTypeData> data in NodeCanvasManager.CanvasTypes)
                {
                    menu.AddItem(new GUIContent("New Canvas/" + data.Value.DisplayString), false, newCanvasTypeCallback, data.Value);
                }

                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Load Canvas", "Loads an Specified Empty CanvasType"), false, LoadCanvas);
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
                menu.AddSeparator("");

                // Load from canvas
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave);
                }

                // Save Canvas to Scene
                menu.AddItem(new GUIContent("Save Canvas to Scene"), false, () =>
                {
                    showModalPanel = true;
                    Debug.Log(showModalPanel);
                });

                menu.ShowAsContext();
            }

            if (GUILayout.Button("Debug", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                var menu = new GenericMenu();

                // Toggles side panel
                menu.AddItem(new GUIContent("Sidebar"), showSideWindow, () => { showSideWindow = !showSideWindow; });

                menu.ShowAsContext();
            }

            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), "ToolbarButton");
            GUILayout.Label("Type: " + canvasCache.typeData.DisplayString + "/" + canvasCache.nodeCanvas.GetType().Name + "", "ToolbarButton");

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

            if (GUILayout.Button("Force Re-init", EditorStyles.toolbarButton, GUILayout.Width(80)))
            {
                NodeEditor.ReInit(true);
            }

            EditorGUILayout.EndHorizontal();
            GUI.backgroundColor = Color.white;
        }
        private void DrawToolbarGUI()
        {
            EditorGUILayout.BeginHorizontal("Toolbar");
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f);

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

                // Canvas creation
                foreach (System.Collections.Generic.KeyValuePair <Type, NodeCanvasTypeData> data in NodeCanvasManager.CanvasTypes)
                {
                    menu.AddItem(new GUIContent("New Canvas/" + data.Value.DisplayString), false, CreateCanvasCallback, data.Key);
                }
//				menu.AddItem(new GUIContent("New Standard Canvas"), false, CreateCanvasCallback, null);
                menu.AddSeparator("");

                // Scene Saving
                menu.AddItem(new GUIContent("Load Canvas", "Loads an asset canvas"), false, LoadCanvas);
                menu.AddItem(new GUIContent("Reload Canvas", "Restores the current canvas to when it has been last saved."), false, ReloadCanvas);
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
                menu.AddSeparator("");

                // Scene Saving
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    if (sceneSave.ToLower() != "lastsession")
                    {
                        menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave);
                    }
                }
                menu.AddItem(new GUIContent("Save Canvas to Scene"), false, () => showModalPanel = true);

                menu.DropDown(new Rect(5, toolbarHeight, 0, 0));
            }

            if (GUILayout.Button("Debug", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu();

                // Toggles side panel
                menu.AddItem(new GUIContent("Sidebar"), showSideWindow, () => showSideWindow = !showSideWindow);

                menu.DropDown(new Rect(55, toolbarHeight, 0, 0));
            }

            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), "ToolbarButton");
            GUILayout.Label("Type: " + canvasCache.typeData.DisplayString /*+ "/" + canvasCache.nodeCanvas.GetType ().Name*/, "ToolbarButton");

            GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1);
            if (GUILayout.Button("Force Re-init", EditorStyles.toolbarButton, GUILayout.Width(80)))
            {
                NodeEditor.ReInit(true);
            }
            GUI.backgroundColor = Color.white;

            EditorGUILayout.EndHorizontal();
        }