码迷,mamicode.com
首页 > 其他好文 > 详细

批量设置AssetBundleName

时间:2016-03-03 19:13:59      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;

public class ChangeName : MonoBehaviour {

//    public string versionDir;
//    public string abName;

    void Start () 
    {
        for(int i = 0;i< 27;i++)
        {
            string path = "RES/com/face/prefab/0_"+i;
            string abname = "face0_" + i;
            SetVersionDirAssetName (path,abname);
        }
    }
    
    public void SetVersionDirAssetName(string versionDir,string abName)
    {
        var fullPath = Application.dataPath + "/" + versionDir + "/";
        var relativeLen = versionDir.Length + 8; // Assets 长度
        if (Directory.Exists(fullPath))
        {
            EditorUtility.DisplayProgressBar("设置AssetName名称", "正在设置AssetName名称中...", 0f);
            var dir = new DirectoryInfo(fullPath);
            var files = dir.GetFiles("*", SearchOption.AllDirectories);
            for (var i = 0; i < files.Length; ++i)
            {
                var fileInfo = files[i];
                EditorUtility.DisplayProgressBar("设置AssetName名称", "正在设置AssetName名称中...", 1f * i / files.Length);
                if (!fileInfo.Name.EndsWith(".meta"))
                {
                    var basePath = fileInfo.FullName.Substring(fullPath.Length - relativeLen).Replace(\\, /);
                    var importer = AssetImporter.GetAtPath(basePath);
                    if (importer && importer.assetBundleName != versionDir)
                    {
                        importer.assetBundleName = abName;
                    }
                }
            }
            EditorUtility.ClearProgressBar();
        }
    }
}

 

批量设置AssetBundleName

标签:

原文地址:http://www.cnblogs.com/602147629/p/5239628.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!