private IEnumerator LoadAnimationInfoFromAssetBundle(CreateAnimationRequest request)
        {
            Debug.Assert(m_mainBundle);
            AssetBundleRequest abRequest = m_mainBundle.LoadAssetAsync(request.prefab.name);

            yield return(abRequest);

            bool find = false;
            InstanceAnimationInfo info = null;

            if (m_animationInfo.TryGetValue(request.prefab, out info))
            {
                find = true;
                request.instance.Prepare(info.listAniInfo, info.extraBoneInfo);
            }

            if (abRequest != null && !find)
            {
                TextAsset    asset  = abRequest.asset as TextAsset;
                BinaryReader reader = new BinaryReader(new MemoryStream(asset.bytes));
                info               = new InstanceAnimationInfo();
                info.listAniInfo   = ReadAnimationInfo(reader);
                info.extraBoneInfo = ReadExtraBoneInfo(reader);
                AnimationInstancingMgr.Instance.ImportAnimationTexture(request.prefab.name, reader);
                request.instance.Prepare(info.listAniInfo, info.extraBoneInfo);
                m_animationInfo.Add(request.prefab, info);
            }
        }
예제 #2
0
        public InstanceAnimationInfo FindAnimationInfo(string cfgName, AnimationInstancing instance)
        {
//            Debug.Assert(prefab != null);
            InstanceAnimationInfo info = null;

            if (m_animationInfo.TryGetValue(cfgName, out info))
            {
                return(info);
            }

//#if UNITY_IPHONE || UNITY_ANDROID
//            Debug.Assert(m_useBundle);
//			if (m_mainBundle == null)
//              Debug.LogError("You should call LoadAnimationAssetBundle first.");
//#endif
            if (m_useBundle)
            {
                CreateAnimationRequest request = new CreateAnimationRequest();
                request.cfgName  = cfgName;
                request.instance = instance;
                if (m_mainBundle != null)
                {
                    StartCoroutine(LoadAnimationInfoFromAssetBundle(request));
                }
                else
                {
                    m_requestList.Add(request);
                }
                return(null);
            }
            else
            {
                return(CreateAnimationInfoFromFile(cfgName));
            }
        }
        private void Update()
        {
            if (m_mainBundle == null || m_requestList.Count == 0)
            {
                return;
            }

            for (int i = 0; i != m_requestList.Count; ++i)
            {
                CreateAnimationRequest request = m_requestList[i];
                StartCoroutine(LoadAnimationInfoFromAssetBundle(request));
            }
            m_requestList.Clear();
        }