当前位置:   article > 正文

Unity---EditorWindow创建文件夹并设置AssetBundleName与后缀_unity shaderbundlenaming 后缀

unity shaderbundlenaming 后缀

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();

        }
    }

}
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/81984
推荐阅读
相关标签
  

闽ICP备14008679号