Exemple #1
0
        static string RequireSubfolder(string name)
        {
            string rootPath   = PathToRootFolder;
            string folderPath = IOHelpers.RequireFolder(rootPath, name);

            return(folderPath);
        }
        void CreateMap()
        {
            string rootPath      = IOHelpers.RequireFolder(ROOT_FOLDER);
            string mapFolderPath = IOHelpers.RequireFolder(rootPath, MAP_FOLDER);
            string mapPath       = IOHelpers.GetAvailableAssetPath(mapFolderPath, MAP_NAME);
            string configName;

            switch (caveGenType)
            {
            case CaveGeneratorUI.CaveGeneratorType.ThreeTiered:
                configName = THREE_TIER_CONFIG_NAME;
                break;

            case CaveGeneratorUI.CaveGeneratorType.RockOutline:
                configName = ROCK_CAVE_CONFIG_NAME;
                break;

            default:
                throw CaveGenTypeException;
            }
            string             property       = string.Format("{0}.{1}", configName, MAP_GEN_NAME);
            SerializedProperty mapGenProperty = serializedObject.FindProperty(property);
            var mapGen  = (MapGenModule)mapGenProperty.objectReferenceValue;
            var map     = mapGen.Generate();
            var texture = map.ToTexture();

            IOHelpers.SaveTextureAsPNG(texture, mapPath);
        }
        void CreateMap()
        {
            string rootPath      = IOHelpers.RequireFolder(ROOT_FOLDER);
            string mapFolderPath = IOHelpers.RequireFolder(rootPath, MAP_FOLDER);
            string mapPath       = IOHelpers.GetAvailableAssetPath(mapFolderPath, MAP_NAME);
            var    mapGen        = GetMapGenModule();
            var    map           = mapGen.Generate();
            var    texture       = map.ToTexture();

            IOHelpers.SaveTextureAsPNG(texture, mapPath);
        }
        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;
            }
        }