通过assetbundle加载的单独打包AnimatorController使用下面方法赋值
Go.GetComponent<Animator>().runtimeAnimatorController = (RuntimeAnimatorController) obj;
通过Resouce.load 加载的AnimatorController使用
Go.GetComponent<Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(obj);
原因是Resouce实际没真正加载资源,而bundle方式资源以及被加载进来了
猜测是Resouce导入的没有引用计数,不会自动clone,而bundle会自动clone,并使用引用计数
IEnumerator Download(string url)
{
WWW www = new WWW(url);
yield return www;
if (www.isDone)
{
if (!string.IsNullOrEmpty(www.error))
{
Debug.LogError(www.error);
yield return true;
}
Object obj = [url=http://www.assetBundle.mainAsset]www.assetBundle.mainAsset[/url];
if (obj != null)
{
m_npc.GetComponent<Animator>().runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(obj);
}
}
}