查看: 863|回复: 0
打印 上一主题 下一主题

[经验分享] 开发技巧-一键创建工程需要的文件夹

[复制链接]

9903

主题

126

听众

7万

积分

首席设计师

Rank: 8Rank: 8

纳金币
53464
精华
316

最佳新人 热心会员 灌水之王 活跃会员 突出贡献 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2018-8-16 01:09:42 |只看该作者 |倒序浏览
  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
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-22 00:02 , Processed in 0.091150 second(s), 29 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部