首先是打包 打包之前博客有写过 和打其他资源的ab包的形式一样 不再赘述 附上之前的连接打包ab
打包的话就是选中做好的AnimatorController 选择打包
打完包可以在目录下找到
具体路径啥的看上边打包链接里边的
总结 打包的是AnimatorController文件 不是animation文件
然后就可以准备加载了
其次是加载 当然 都是ab包 加载方式与其他的也大概一致 唯一不同的是取值
IEnumerator Load()
{
string path = @"file:F:/FinGis/Assets/"+ "main camera";
print(path);
WWW www = new WWW(path);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
var runtimeAnimatorController = www.assetBundle.LoadAsset<RuntimeAnimatorController>("main camera.controller");
gameObject.GetComponent<Animator>().runtimeAnimatorController = runtimeAnimatorController;
}
else
{
print(www.error);
}
}
虽然打包的是AnimatorController文件 但是加载的类型却是runtimeAnimatorController 这一点要注意.然后直接覆盖掉animator的controller就行了. animator还是比较方便的 animation的话 是这样
打包的时候选择的是animation文件 加载的时候的类型是AnimationClip 然后给animoation的clip赋值大致如下图
animation不细说. 基本不怎么用了
注意 后边要跟上ab包文件内的资源名称 如果你实在不知道 也是可以先遍历一遍所有的资源名称的
遍历方式: foreach (var item in www.assetBundle.GetAllAssetNames()) 巴拉巴拉
好久没更新博客了 懒惰了懒惰了啊