void CreateMeshAsset(Transform component, string path)
        {
            Mesh mesh = ExtractMesh(component.gameObject);

            path = IOHelpers.CombinePath(path, component.name);
            AssetDatabase.CreateAsset(mesh, path);
        }
Esempio n. 2
0
        /// <summary>
        /// Load the editor from the last session. Returns null if none found.
        /// </summary>
        public static ChartEditorSave Load()
        {
            string path = IOHelpers.CombinePath(assets, resources, assetNameWithExtension);
            var    save = EditorGUIUtility.Load(path) as ChartEditorSave;

            return(save);
        }
        /// <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);
        }
        void CreatePrefab(GameObject cave)
        {
            string rootFolderPath   = IOHelpers.RequireFolder(ROOT_FOLDER);
            string caveFolderPath   = IOHelpers.RequireFolder(rootFolderPath, PREFAB_FOLDER);
            string prefabFolderPath = IOHelpers.CreateFolder(caveFolderPath, CAVE_FOLDER);

            try
            {
                CreateMeshAssets(cave.transform, prefabFolderPath);
                string path = IOHelpers.CombinePath(prefabFolderPath, PREFAB_NAME);
                PrefabUtility.CreatePrefab(path, cave);
            }
            catch (InvalidOperationException)
            {
                AssetDatabase.DeleteAsset(prefabFolderPath);
                throw;
            }
        }
        /// <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);
        }