赞
踩
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Windows.Forms;
public class CreateFolder : EditorWindow {
private static CreateFolder window;
string curText = "";
[UnityEditor.MenuItem("MyTool/Create Folder")]
public static void Init()
{
window = (CreateFolder)EditorWindow.GetWindow(typeof(CreateFolder),true,"创建资源文件夹");
window.Show();
}
void OnGUI()
{
GUILayout.Label("文件夹名:(将包名中的'.'换成'_'即可)",EditorStyles.boldLabel);
GUILayout.Label("如:com_rethink_jigsaw_free",EditorStyles.boldLabel);
curText = EditorGUILayout.TextField("输入包名:",curText);
if (GUI.Button (new Rect (100, 80, 180, 70), "Click to create Assets Folder"))
{
if (curText.Equals (null) || curText.Equals("")) {
MessageBox.Show("请先输入文件名");
return;
}
string prjPath = UnityEngine.Application.dataPath + "/GameAssets/"+curText+"/";
DirectoryInfo mydir = new DirectoryInfo(prjPath);
if(mydir.Exists)
{
Toast.instance.ShowMessage ("该文件夹已存在",1.5f);
return;
}
Directory.CreateDirectory(prjPath + "images");
Directory.CreateDirectory(prjPath + "frames");
Directory.CreateDirectory(prjPath + "videos");
AssetDatabase.Refresh ();
MessageBox.Show ("游戏资源文件夹创建完成");
string imagePath = "Assets" + prjPath.Substring(UnityEngine.Application.dataPath.Length)+"images";
AssetImporter asset = AssetImporter.GetAtPath(imagePath);
asset.assetBundleName = "images_"+curText; //设置Bundle文件的名称
asset.assetBundleVariant = "ab";//设置Bundle文件的扩展名
asset.SaveAndReimport();
string framesPath = "Assets" + prjPath.Substring(UnityEngine.Application.dataPath.Length)+"frames";
AssetImporter asset1 = AssetImporter.GetAtPath(framesPath);
asset1.assetBundleName = "frames_"+curText;
asset1.assetBundleVariant = "ab";
asset1.SaveAndReimport();
// string videosPath = "Assets" + prjPath.Substring(UnityEngine.Application.dataPath.Length)+"videos";
// AssetImporter asset2 = AssetImporter.GetAtPath(videosPath);
// asset2.assetBundleName = "videos_"+curText;
// asset2.assetBundleVariant = "ab";
// asset2.SaveAndReimport();
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。