Unity5.X批清理AssetBundle的名称

来源:互联网 发布:python list函数 编辑:程序博客网 时间:2024/05/29 12:14
[MenuItem("Assets/平台打包/清理AssetBundle名字")]    static public void ClearBundleFileName()    {        string path = Application.dataPath + "/Resources";        string[] files = System.IO.Directory.GetFiles( path, "*.*", SearchOption.AllDirectories);        if( ( files != null ) && ( files.Length > 0 ) )        {            for( int i = 0; i < files.Length; ++i )            {                string fileName = files[ i ];                string localPath = AssetBunbleInfo.GetLocalPath(fileName);                if( !string.IsNullOrEmpty( localPath ) )                {                    localPath = localPath.ToLower();                }                if( AssetBundleBuild.FileIsResource( localPath ) )                {                    AssetImporter importer = AssetImporter.GetAtPath(localPath);                    if( importer != null )                    {                        importer.assetBundleName = string.Empty;                    }                }            }        }        AssetDatabase.RemoveUnusedAssetBundleNames();    }

注意:localPath是Assets下的路径

比如:有个资源C://MyClinet/Assets/Resources/xxx.prefab。localPath就是:Assets/Resources/xxx.prefab

0 0
原创粉丝点击