コード例 #1
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();
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
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;
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
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);
        }
コード例 #9
0
        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;
            }
        }