Unity学习笔记

自用生成文件夹脚本

一键生成文件夹


/**************************************************************************
 * Author: DuYouLu
 * Description:
**************************************************************************/
using UnityEngine;
using System.Collections;
using System.IO;

#if UNITY_EDITOR
using UnityEditor;
#endif

/// 
/// 生成基本的文件夹
/// 
public class GenerateFolders : MonoBehaviour
{
#if UNITY_EDITOR
    [MenuItem("DYLTools/CreateBasicFolder #&_b")]
    private static void CreateBasicFolder()
    {
        GenerateFolder(DirectoryStructure.ClassicBasic);
        Debug.Log("Folders Created");
    }


    [MenuItem("DYLTools/CreateALLFolder")]
    private static void CreateAllFolder()
    {
        GenerateFolder(DirectoryStructure.ClassicAll);
        Debug.Log("Folders Created");
    }


    [MenuItem("DYLTools/CreateCompanyFolder")]
    private static void CreateCompanyFolder()
    {
        GenerateFolder(DirectoryStructure.Company);
        Debug.Log("Folders Created");
    }


    private static void GenerateFolder(DirectoryStructure directoryStructure)
    {
        string _path = Application.dataPath + "/";

        switch(directoryStructure)
        {
            case DirectoryStructure.ClassicBasic:
                Directory.CreateDirectory(_path + "Audio");
                Directory.CreateDirectory(_path + "Prefabs");
                Directory.CreateDirectory(_path + "Materials");
                Directory.CreateDirectory(_path + "Resources");
                Directory.CreateDirectory(_path + "Scripts");
                Directory.CreateDirectory(_path + "Textures");
                Directory.CreateDirectory(_path + "Scenes");
                break;
            case DirectoryStructure.ClassicAll:
                Directory.CreateDirectory(_path + "Audio");
                Directory.CreateDirectory(_path + "Audio" + "/" + "Music");
                Directory.CreateDirectory(_path + "Audio" + "/" + "SFX");
                Directory.CreateDirectory(_path + "Prefabs");
                Directory.CreateDirectory(_path + "Materials");
                Directory.CreateDirectory(_path + "Resources");
                Directory.CreateDirectory(_path + "Scripts");
                Directory.CreateDirectory(_path + "Textures");
                Directory.CreateDirectory(_path + "Scenes");
                Directory.CreateDirectory(_path + "Meshes");
                Directory.CreateDirectory(_path + "Shaders");
                Directory.CreateDirectory(_path + "GUI");
                Directory.CreateDirectory(_path + "StreamingAssets");
                Directory.CreateDirectory(_path + "Plugins");
                Directory.CreateDirectory(_path + "Editor");
                Directory.CreateDirectory(_path + "Plugins");
                Directory.CreateDirectory(_path + "Fonts");
                break;
            case DirectoryStructure.Company:
                Directory.CreateDirectory(_path + "External Assets");
                Directory.CreateDirectory(_path + "Project Assets");
                Directory.CreateDirectory(_path + "Project Assets" + "/" + "Image");
                Directory.CreateDirectory(_path + "Project Assets" + "/" + "Atlas");
                Directory.CreateDirectory(_path + "Project Assets" + "/" + "Animator");
                Directory.CreateDirectory(_path + "Models");
                Directory.CreateDirectory(_path + "Prefabs");
                Directory.CreateDirectory(_path + "Resources");
                Directory.CreateDirectory(_path + "Scenes");
                Directory.CreateDirectory(_path + "Scripts");
                break; 
        }
        AssetDatabase.Refresh();
    }
#endif
}

public enum DirectoryStructure
{
    ClassicBasic,
    ClassicAll,
    Company
}





你可能感兴趣的:(unity,Unity,学习笔记)