public static void RequestLoad(NodeCanvas _canvas)
        {
            string assetPath = AssetDatabase.GetAssetPath(_canvas);

            NodeEditor.curEditorState = null;
            canvasCache.LoadNodeCanvas(assetPath);
            canvasCache.NewEditorState();
        }
Пример #2
0
        public void DrawSideWindow()
        {
            GUILayout.Label(new GUIContent("TextureWang ", "Opened Canvas path: " + openedCanvasPath), NodeEditorGUI.nodeLabelBold);

            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);
                }

/*
 *              string path = EditorUtility.SaveFilePanelInProject ("Save Node Canvas", m_LastLoadedName, "asset", "", NodeEditor.editorPath + "Resources/Saves/");
 *                          if (!string.IsNullOrEmpty(path))
 *                          {
 *                              SaveNodeCanvas(path);
 *
 *              }
 */
                if (m_NodeSelectionWindow != null)
                {
                    m_NodeSelectionWindow.ReInit();
                }
            }

            /*
             *          if (GUILayout.Button(new GUIContent("New Canvas",
             *                  "Create a copy")))
             *          {
             *              CreateEditorCopy();
             *          }
             */

            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
                {
                    NodeEditor.curEditorState = null;
                    canvasCache.LoadNodeCanvas(path);
                    canvasCache.NewEditorState();
                }
            }

            if (GUILayout.Button(new GUIContent("New TextureWang", "Create a new TextureWang Canvas")))
            {
                NewTextureWangPopup.Init(this);
            }


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

            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);

            //miked            mainNodeCanvas.scaleMode = (ScaleMode)EditorGUILayout.EnumPopup(new GUIContent("ScaleMode", ""), mainNodeCanvas.scaleMode, GUILayout.MaxWidth(200));



            //        m_OpType = (TexOP)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Type", "The type of calculation performed on Input 1"), m_OpType, GUILayout.MaxWidth(200));
            //            if (mainNodeCanvas != null)
            {
                //                EditorGUILayout.LabelField("width: " + mainNodeCanvas.m_TexWidth);
                //                EditorGUILayout.LabelField("height: " + mainNodeCanvas.m_TexHeight);
            }

/*
 *          if (NodeEditor.curEditorState == null)
 *          {
 *              Debug.Log("TWWindow has no editor state " + NodeEditor.curEditorState);
 *          }
 *          else if (NodeEditor.curEditorState.selectedNode == null)
 *          {
 *              Debug.Log("TWWindow has no Selected Node " + NodeEditor.curEditorState);
 *          }
 *          else
 *          {
 *              Debug.Log(" Selected Node " + NodeEditor.curEditorState.selectedNode);
 *          }
 */
            if (canvasCache.editorState != null && canvasCache.editorState.selectedNode != null)
            // if (Event.current.type != EventType.Ignore)
            {
                RTEditorGUI.Seperator();
                GUILayout.Label(canvasCache.editorState.selectedNode.name);
                RTEditorGUI.Seperator();
                canvasCache.editorState.selectedNode.DrawNodePropertyEditor();
                if (GUI.changed)
                {
                    NodeEditor.RecalculateFrom(PriorLoop(canvasCache.editorState.selectedNode));
                }
            }


            //            var assets = UnityEditor.AssetDatabase.FindAssets("NodeCanvas");
            //            foreach(var x in assets)
            //                GUILayout.Label(new GUIContent("Node Editor (" + x + ")", "Opened Canvas path: " ), NodeEditorGUI.nodeLabelBold);

            /*
             *          if (m_All == null)
             *              m_All = GetAtPath<NodeCanvas>("Node_Editor-master/Node_Editor/Resources/Saves");//Resources.LoadAll<NodeCanvas>(NodeEditor.editorPath + "Resources/Saves/");
             *
             *          scrollPos =EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(300), GUILayout.Height(600));
             *          guiStyle.fontSize = 20;
             *          guiStyle.fixedHeight = 20;
             *          foreach (var x in m_All)
             *               EditorGUILayout.SelectableLabel("(" + x.name + ")", guiStyle);
             *          EditorGUILayout.EndScrollView();
             */
        }