unity小工具 创建常用文件夹
当我们新建一个unity工程时候,并不会赠送我们一整套的资源文件夹目录,需要我们自己去手动创建,十分麻烦还有可能写错.
这里介绍一个小工具用来创建常用文件夹 在unity中创建一个脚本,直接上代码
using UnityEngine; using System.IO; #if UNITY_EDITOR using UnityEditor; #endif public class NewBehaviourScript : MonoBehaviour { #if UNITY_EDITOR [MenuItem("Tools/CreateFolder #&_b")] private static void GenerateFolder() { 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"); Directory.CreateDirectory(prjPath + "Animation"); Directory.CreateDirectory(prjPath + "AnimationController"); Directory.CreateDirectory(prjPath + "Plugins"); Directory.CreateDirectory(prjPath + "Plugins/iOS"); Directory.CreateDirectory(prjPath + "Plugins/Android"); Directory.CreateDirectory(prjPath + "Editor"); Directory.CreateDirectory(prjPath + "Particle"); Directory.CreateDirectory(prjPath + "Meshes"); Directory.CreateDirectory(prjPath + "Shaders"); Directory.CreateDirectory(Application.streamingAssetsPath); AssetDatabase.Refresh();//刷新unity资源显示 Debug.Log("Created Finished"); } #endif }
编译完成之后可以点击 Tools ->CreateFolder 创建常用文件夹
效果如下:
注意:如果有已经存在的文件夹,那么在创建的时候原来的文件不会被清空