Exemplo n.º 1
0
        /// <summary>
        /// Load the editor from the last session. If a previous editor is not found, returns an empty save which
        /// can be consumed like a non-empty one - in particular, never returns null.
        /// </summary>
        public static NodeEditorSave Load()
        {
            NodeEditorSave save = null;

            save = EditorGUIUtility.Load(IOHelpers.CombinePath(assets, resources, assetNameWithExtension)) as NodeEditorSave;
            if (save == null)
            {
                save = CreateInstance <NodeEditorSave>();
            }
            Assert.IsNotNull(save);
            return(save);
        }
Exemplo n.º 2
0
        void Load()
        {
            var savedEditor = NodeEditorSave.Load();

            if (savedEditor == null)
            {
                nodes = new List <NodeGroup>();
                return;
            }

            dragOffset = savedEditor.Offset; // Important: restore offset before restoring nodes.
            nodes      = new List <NodeGroup>();
            foreach (SavedNode savedNode in savedEditor.Nodes)
            {
                AddNode(savedNode.NodeRect, savedNode.MapGenModule);
            }
        }
Exemplo n.º 3
0
        public static void Save(NodeEditorSave save)
        {
            Assert.IsNotNull(save);
            Assert.IsTrue(save.Nodes.All(node => node != null));
            string folderPath = Path.Combine(assets, resources);

            if (!AssetDatabase.IsValidFolder(folderPath))
            {
                AssetDatabase.CreateFolder(assets, resources);
            }
            string assetPath = Path.Combine(folderPath, assetNameWithExtension);

            if (IOHelpers.AssetExists(assetName, folderPath))
            {
                AssetDatabase.DeleteAsset(assetPath);
            }
            AssetDatabase.CreateAsset(save, assetPath);
            AssetDatabase.SaveAssets();
        }
        /// <summary>
        /// Load the editor from the last session. If a previous editor is not found, returns an empty save which
        /// can be consumed like a non-empty one - in particular, never returns null.
        /// </summary>
        public static NodeEditorSave Load()
        {
            NodeEditorSave save = null;

            if (EditorPrefs.GetBool(loadKey))
            {
                save = EditorGUIUtility.Load(IOHelpers.CombinePath(assets, resources, assetNameWithExtension)) as NodeEditorSave;
            }
            if (save == null)
            {
                save = CreateInstance <NodeEditorSave>();
            }
            else
            {
                // Deep copy all nodes so that we're not maintaining any references to the saved asset.
                // Otherwise, the references will break when we delete the asset.
                //save = save.CopyDeep();
            }
            Assert.IsNotNull(save);
            return(save);
        }
        public static void Save(NodeEditorSave save)
        {
            Assert.IsNotNull(save);
            Assert.IsTrue(save.Nodes.All(node => node != null));
            string folderPath = Path.Combine(assets, resources);

            if (!AssetDatabase.IsValidFolder(folderPath))
            {
                AssetDatabase.CreateFolder(assets, resources);
            }
            string assetPath = Path.Combine(folderPath, assetNameWithExtension);

            if (IOHelpers.AssetExists(assetName, folderPath))
            {
                AssetDatabase.DeleteAsset(assetPath);
            }
            AssetDatabase.CreateAsset(save, assetPath);
            //save = save.CopyDeep();
            //ScriptableObjectHelpers.SaveCompoundScriptableObject(save, assetPath);
            EditorPrefs.SetBool(loadKey, true);
            AssetDatabase.SaveAssets();
        }
Exemplo n.º 6
0
 void Save()
 {
     savedEditor = NodeEditorSave.CreateSave(nodes, dragOffset);
     NodeEditorSave.Save(savedEditor);
 }