Пример #1
0
        private void SaveSceneCanvasPanel()
        {
            GUILayout.Label("Save Canvas To Scene");

            GUILayout.BeginHorizontal();
            sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true));
            bool overwrite = NodeEditorSaveManager.HasSceneSave(sceneCanvasName);

            if (overwrite)
            {
                GUILayout.Label(new GUIContent("!!!", "A canvas with the specified name already exists. It will be overwritten!"), GUILayout.ExpandWidth(false));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Cancel"))
            {
                showModalPanel = false;
            }
            if (GUILayout.Button(new GUIContent(overwrite ? "Overwrite" : "Save", "Save the canvas to the Scene")))
            {
                showModalPanel = false;
                if (!string.IsNullOrEmpty(sceneCanvasName))
                {
                    canvasCache.SaveSceneNodeCanvas(sceneCanvasName);
                }
            }
            GUILayout.EndHorizontal();
        }
Пример #2
0
        // Modal GUI.Window for save scene input
        void DoModalWindow(int unusedWindowID)
        {
            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)))
            {
                canvasCache.SaveSceneNodeCanvas(sceneCanvasName);
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Close"))
            {
                showModalPanel = false;
            }
        }
Пример #3
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();
            }
        }
Пример #4
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 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();
            }
        }