Exemple #1
0
        public static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath)
        {
            //check if we are moving a procedural worlds directory
            if (Directory.Exists(fromPath))
            {
                string folderName = Path.GetFileName(fromPath);
                string assetPath  = fromPath + "/" + folderName + ".asset";

                if (!File.Exists(assetPath))
                {
                    return(AssetMoveResult.DidNotMove);
                }

                WorldGraph worldGraph = AssetDatabase.LoadMainAssetAtPath(assetPath) as WorldGraph;

                if (worldGraph == null)
                {
                    return(AssetMoveResult.DidNotMove);
                }

                string toFolderName = Path.GetFileName(toPath);
                string newAssetPath = toPath + "/" + toFolderName + ".asset";

                if (String.IsNullOrEmpty(GraphFactory.GetWorldGraphCreateLocation(toPath)))
                {
                    Debug.LogError("Can't move the Procedural world directory to " + newAssetPath + ": Not a Resources directory");
                    return(AssetMoveResult.FailedMove);
                }

                Debug.Log("Moving main asset from " + assetPath + " to " + newAssetPath);
                AssetDatabase.MoveAsset(assetPath, newAssetPath);
            }

            return(AssetMoveResult.DidNotMove);
        }
        void GraphChangedCallback(BaseGraph newGraph)
        {
            if (newGraph == null)
            {
                return;
            }

            string path = AssetDatabase.GetAssetPath(newGraph);

            if (String.IsNullOrEmpty(GraphFactory.GetWorldGraphCreateLocation(path)))
            {
                Debug.LogWarning("Your main graph is not inside a Resources folder/don't have a dedicated folder");
            }
        }
Exemple #3
0
        private static void CreateNodeCSharpScritpt()
        {
            string path = GraphFactory.GetCurrentPath() + "/" + nodeBaseName;

            path = AssetDatabase.GenerateUniqueAssetPath(path);

            ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
                0,
                ScriptableObject.CreateInstance <DoCreateNodeScript>(),
                path,
                EditorGUIUtility.FindTexture("cs Script Icon"),
                null
                );

            AssetDatabase.Refresh();
        }
Exemple #4
0
        public override void Action(int instanceId, string pathName, string resourceFile)
        {
            var name = Path.GetFileName(pathName);
            var guid = AssetDatabase.CreateFolder(Path.GetDirectoryName(pathName), name);

            string folderPath = AssetDatabase.GUIDToAssetPath(guid);

            var folderAsset = AssetDatabase.LoadAssetAtPath(folderPath, typeof(Object));

            ProjectWindowUtil.ShowCreatedAsset(folderAsset);

            var graph = GraphFactory.CreateGraph <WorldGraph>(folderPath, name, false);

            ProjectWindowUtil.ShowCreatedAsset(graph);

            //create Biome folder:
            AssetDatabase.CreateFolder(folderPath, GraphFactory.baseGraphBiomeFolderName);
        }
 public static void CreateNewProceduralBiome()
 {
     GraphFactory.CreateBiomeGraph();
 }
 public static void CreateNewProceduralWorld()
 {
     GraphFactory.CreateWorldGraph();
 }