Unity 5.x 的新版AssetBundle打包方式有了很大的变化,所以我写了个编辑器来批量修改资源依赖的AssetbundleName
[MenuItem("AssetBundle/BuildAssetBundles")] public static void BuildAssetBundles() { string outputPath = "Assets/bundles"; foreach (Object o in Selection.GetFiltered(typeof(Object),SelectionMode.DeepAssets)) { //得到指定资源路径 string path = AssetDatabase.GetAssetPath(o); //得到指定资源的bundle名字 string abName = AssetImporter.GetAtPath(path).assetBundleName; //得到指定资源的依赖资源路径 string[] depends=AssetDatabase.GetDependencies(path); //修改所有依赖的bundle名 foreach (string dp in depends) { if (dp.EndsWith(".cs") || dp.EndsWith(".js")) continue; AssetImporter ai = AssetImporter.GetAtPath(dp); ai.assetBundleName = abName; } } //生成bundle包的路径 if (!Directory.Exists(outputPath)) Directory.CreateDirectory(outputPath); //把已经赋值AssetBundleName的Object全部打包到指定目录中 BuildPipeline.BuildAssetBundles(outputPath); AssetDatabase.Refresh(); Debug.Log("Build AssetBundle Success"); }
原文地址:https://www.jb51.cc/javaschema/284189.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。