纳金网

标题: 开发技巧-一键创建工程需要的文件夹 [打印本页]

作者: 烟雨    时间: 2018-8-16 01:09
标题: 开发技巧-一键创建工程需要的文件夹
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.IO;
  4. #if UNITY_EDITOR
  5. using UnityEditor;
  6. #endif

  7. public class GenerateFolders : MonoBehaviour
  8. {
  9. #if UNITY_EDITOR
  10.     [MenuItem("Tools/CreateBasicFolder #&_b")]
  11.     private static void CreateBasicFolder()
  12.     {
  13.         GenerateFolder();
  14.         Debug.Log("Folders Created");
  15.     }
  16.     [MenuItem("Tools/CreateALLFolder")]
  17.     private static void CreateAllFolder()
  18.     {
  19.         GenerateFolder(1);
  20.         Debug.Log("Folders Created");
  21.     }
  22.     private static void GenerateFolder(int flag = 0)
  23.     {
  24.         // 文件路径
  25.         string prjPath = Application.dataPath + "/";
  26.         Directory.CreateDirectory(prjPath + "Audio");
  27.         Directory.CreateDirectory(prjPath + "Prefabs");
  28.         Directory.CreateDirectory(prjPath + "Materials");
  29.         Directory.CreateDirectory(prjPath + "Resources");
  30.         Directory.CreateDirectory(prjPath + "Scripts");
  31.         Directory.CreateDirectory(prjPath + "Textures");
  32.         Directory.CreateDirectory(prjPath + "Scenes");
  33.         if (1 == flag)
  34.         {
  35.             Directory.CreateDirectory(prjPath + "Meshes");
  36.             Directory.CreateDirectory(prjPath + "Shaders");
  37.             Directory.CreateDirectory(prjPath + "GUI");
  38.         }
  39.         AssetDatabase.Refresh();
  40.     }
  41. #endif
  42. }
复制代码
来自:UnityTerminator





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5