在做unity项目中,首先要创建好分类的文件夹,现在通过写代码的方式减少了手动创建文件夹这一步骤;
private void Start() { CreateBasicFolder(); } #if UNITY_EDITOR [MenuItem("Tools/CreateBasicFolder #&_b")] private static void CreateBasicFolder() { GenerateFolder(); Debug.Log("Folders Created"); } [MenuItem("Tools/CreateALLFolder")] private static void CreateAllFolder() { GenerateFolder(1); Debug.Log("Folders Created"); } private static void GenerateFolder(int flag = 0) { // 文件路径 string prjPath = Application.dataPath + "/"; Directory.CreateDirectory(prjPath + "Audio"); Directory.CreateDirectory(prjPath + "Prefabs"); Directory.CreateDirectory(prjPath + "Materials"); Directory.CreateDirectory(prjPath + "Resources"); Directory.CreateDirectory(prjPath + "Scripts"); Directory.CreateDirectory(prjPath + "Textures"); Directory.CreateDirectory(prjPath + "Scenes"); if (1== flag) { Directory.CreateDirectory(prjPath + "Meshes"); Directory.CreateDirectory(prjPath + "Shaders"); Directory.CreateDirectory(prjPath + "GUI"); } AssetDatabase.Refresh(); } #endif下面是运行项目后的效果: