Esempio n. 1
0
    public static NoiseNodeCanvas CreateInstance()
    {
        NoiseNodeCanvas noiseNodeCanvas = ScriptableObject.CreateInstance <NoiseNodeCanvas>();

        noiseNodeCanvas.ntf = YamlIO.LoadFile <NoiseTreeFiles>(NoiseTreeFiles.GetPath(), null, null);
        return(noiseNodeCanvas);
    }
Esempio n. 2
0
    private NodeCanvas Load(string name, CompleteLoadCallback onComplete)
    {
        NodeCanvas nodeCanvas   = null;
        string     treeFilePath = NoiseTreeFiles.GetTreeFilePath(name);
        Tree       tree         = YamlIO.LoadFile <Tree>(treeFilePath, null, null);

        if (tree != null)
        {
            if (tree.settings.name == null || tree.settings.name == string.Empty)
            {
                tree.settings.name = name;
            }
            nodeCanvas = PopulateNoiseNodeEditor(tree);
        }
        onComplete(name, nodeCanvas);
        return(nodeCanvas);
    }
Esempio n. 3
0
 public override void AdditionalSaveMethods(string sceneCanvasName, CompleteLoadCallback onComplete)
 {
     GUILayout.BeginHorizontal();
     if (GUILayout.Button(new GUIContent("Load Yaml", "Loads the Canvas from a Yaml Save File")))
     {
         Load(sceneCanvasName, onComplete);
     }
     if (GUILayout.Button(new GUIContent("Save to Yaml", "Saves the Canvas to a Yaml file"), GUILayout.ExpandWidth(false)))
     {
         BeforeSavingCanvas();
         Tree tree = BuildTreeFromCanvas();
         if (tree != null)
         {
             tree.ClearEmptyLists();
             string treeFilePath = NoiseTreeFiles.GetTreeFilePath(sceneCanvasName);
             YamlIO.Save(tree, treeFilePath, null);
         }
     }
     GUILayout.EndHorizontal();
     if (ntf == null)
     {
         ntf = YamlIO.LoadFile <NoiseTreeFiles>(NoiseTreeFiles.GetPath(), null, null);
     }
     if (ntf != null && GUILayout.Button(new GUIContent("Load Tree", "Loads the Canvas from Trees list")))
     {
         GenericMenu genericMenu = new GenericMenu();
         foreach (string tree_file in ntf.tree_files)
         {
             genericMenu.AddItem(new GUIContent(tree_file), false, delegate(object fileName)
             {
                 Load((string)fileName, onComplete);
             }, tree_file);
         }
         genericMenu.Show(lastRectPos.position, 40f);
     }
     if (Event.current.type == EventType.Repaint)
     {
         Rect lastRect = GUILayoutUtility.GetLastRect();
         lastRectPos = new Rect(lastRect.x + 2f, lastRect.yMax + 2f, lastRect.width - 4f, 0f);
     }
 }