AssetBundle的依赖关系 编辑器下由AssetDatabase 和 AssetImporter管理,AssetDatabase管理依赖,AssetImporter为AssetBundle数据 通过AssetDatabase.GetDependencies(path) 来获取该Asset的依赖文件 通过AssetImporter可以修改Asset的AssetBundle设置 实际打包时,会将Asset的依赖关系打进manifest文件,但是加载一个AssetBundle时Unity并不会...
应用必须追踪assetbundles之间的依赖,并且需要确保在调用AssetBundle.LoadAssets加载asset之前,正确的assetbundles被加载进来。 官方建议了第三种,在编辑器时期可以通过AssetDatabase API追踪对象的依赖关系,AssetDatabase.GetDependencies能被用来定位当前特定对象和asset的依赖,依赖可能也有自己的依赖。 在运行时,AssetImporter ...
Material mat = AssetDatabase.LoadAssetAtPath("Assets/Materials/New Material.mat", typeof(Material)) as Material; // 以mat为模板创建mat2 Material mat2 = Object.Instantiate<Material>(mat); // 创建资源 AssetDatabase.CreateAsset(mat2, "Assets/Materials/1.mat"); // 刷新编辑器,使刚创建的资源立...
SerializedObject graphicsSettings =new SerializedObject (AssetDatabase.LoadAllAssetsAtPath ("ProjectSettings/GraphicsSettings.asset") [0]); SerializedProperty it = graphicsSettings.GetIterator (); SerializedProperty dataPoint; while (it.NextVisible(true)) { ...
void ClearAssetBundlesName() { int length = AssetDatabase.GetAllAssetBundleNames().Length; Debug.Log(length); for (int i = length - 1; i >= 0; i--) { string str = AssetDatabase.GetAllAssetBundleNames()[i]; Debug.Log(str); AssetDatabase.RemoveAssetBundleName(...
AssetDatabase.RemoveAssetBundleName(oldAssetBundleNames[j], true); } EditorUtility.ClearProgressBar(); } public static void SetAssetBundlesName() { string fullPath = Application.dataPath + "/GameRes/"; //将Assets/GameRes/文件夹下的所有资源进行打包 ...
string newPath = "Assets" + mypath.Replace(Application.dataPath, ""); newPath = newPath.Replace("\\", "/"); Object obj = AssetDatabase.LoadMainAssetAtPath(newPath); 3.打包函数 我们调用BuildPipeline.BuildAssetBundle来进行打包: BuildPipeline.BuildAssetBundle有5个参数,第一个是主资源,第二个是...
AssetDatabase.Refresh(); 好的,完成了打包我们就可以在我们游戏的根目录下看到如下图: 这些都是我们需要的文件,然而这些文件是什么意思呢?在上一章已经介绍过了,如果不记得的可以回去看看。 好了这次教程就到这里。但是打包好了之后要怎么加载呢?下次的教程将会讲解。
一旦确定了 Source Asset,我们就可以利用 Unity 提供的 API,AssetDatabase.GetDependencies,获取其依赖的 Derived Asset。这样我们就能得到一个参与构建 AB 的完整的 asset 集合,同时,排除了所有不需要的 asset。 1.2 Assigning 一个Source Asset 及其有关的 Derived Asset 总是被同时使用(或同时不使用),而不同的 ...
// 创建资源public class TestCreateAsset:MonoBehaviour{voidStart(){#ifUNITY_EDITOR// 加载资源Material mat=AssetDatabase.LoadAssetAtPath("Assets/Materials/New Material.mat",typeof(Material))as Material;// 以mat为模板创建mat2Material mat2=Object.Instantiate<Material>(mat);// 创建资源AssetDatabase.Crea...