Unity AnimatorController注意事項
阿新 • • 發佈:2019-01-01
通過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); } } }