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);
            }
        }
        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));
            }
        }
        public InstanceAnimationInfo FindAnimationInfo(string pFileName, AnimationInstancing instance)
        {
            Debug.Assert(pFileName != null);
            InstanceAnimationInfo info = null;

            if (m_animationInfo.TryGetValue(pFileName, 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.prefab = prefab;
            //                 request.instance = instance;
            //                 if (m_mainBundle != null)
            //                 {
            //                     StartCoroutine(LoadAnimationInfoFromAssetBundle(request));
            //                 }
            //                 else
            //                 {
            //                     m_requestList.Add(request);
            //                 }
            //                 return null;
            //             }
            //             else
            return(CreateAnimationInfoFromFile(pFileName));
        }
        private InstanceAnimationInfo CreateAnimationInfoFromFile(GameObject prefab)
        {
            Debug.Assert(prefab != null);
            string path;

#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            path = Application.dataPath + "/AnimationTexture/";
#elif UNITY_STANDALONE_OSX
            path = Application.dataPath + "/Resources/Data/StreamingAssets/AnimationTexture/";
#endif

#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
            //Debug.Log("This is the data path:" + path);
            FileStream file = File.Open(path + prefab.name + ".bytes", FileMode.Open);
            Debug.Assert(file.CanRead);
            InstanceAnimationInfo info   = new InstanceAnimationInfo();
            BinaryReader          reader = new BinaryReader(file);
            info.listAniInfo   = ReadAnimationInfo(reader);
            info.extraBoneInfo = ReadExtraBoneInfo(reader);
            m_animationInfo.Add(prefab, info);
            AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader);
            file.Close();
#elif UNITY_IPHONE
            path = "file://" + Application.dataPath + "/Raw/AnimationTexture/";
            WWW w = new WWW(path + prefab.name + ".bytes");
            //wwwLoad(path + "/boneTexture/" + prefab.name + ".aniData", SetupAniInfo);
            while (!w.isDone)
            {
            }
            //if (w.error)
            Debug.Log("This is the data path:" + path);
            Debug.Log(w.error);
            BinaryReader          reader = new BinaryReader(new MemoryStream(w.bytes));
            InstanceAnimationInfo info   = new InstanceAnimationInfo();
            info.listAniInfo   = ReadAnimationInfo(reader);
            info.extraBoneInfo = ReadExtraBoneInfo(reader);
            m_animationInfo.Add(prefab, info);
            AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader);
#elif UNITY_ANDROID
            path = "jar:file://" + Application.dataPath + "!/assets/";
            WWW w = new WWW(path + "AnimationTexture/" + prefab.name + ".bytes");
            //wwwLoad(path + "/boneTexture/" + thisPrefab.name + ".aniData", SetupAniInfo);
            while (!w.isDone)
            {
            }
//             BinaryReader reader = new BinaryReader(new MemoryStream(w.bytes));
//             List<AnimationInfo> listInfo = ReadAnimationInfo(reader);
//             m_animationInfo.Add(prefab, listInfo);
            BinaryReader          reader = new BinaryReader(new MemoryStream(w.bytes));
            InstanceAnimationInfo info   = new InstanceAnimationInfo();
            info.listAniInfo   = ReadAnimationInfo(reader);
            info.extraBoneInfo = ReadExtraBoneInfo(reader);
            m_animationInfo.Add(prefab, info);
            AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader);
#endif
            return(info);
        }
//        private InstanceAnimationInfo CreateAnimationInfoFromFile(GameObject prefab)
//        {
//            Debug.Assert(prefab != null);
//            string path;
//#if UNITY_EDITOR || UNITY_STANDALONE_WIN
//            path = Application.dataPath + "/AnimationTexture/";
//#elif UNITY_STANDALONE_OSX
//		    path = Application.dataPath + "/Resources/Data/StreamingAssets/AnimationTexture/";
//#endif
//
//#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
//            //Debug.Log("This is the data path:" + path);
//            FileStream file = File.Open(path + prefab.name + ".bytes", FileMode.Open);
//            Debug.Assert(file.CanRead);
//            InstanceAnimationInfo info = new InstanceAnimationInfo();
//            BinaryReader reader = new BinaryReader(file);
//            info.listAniInfo = ReadAnimationInfo(reader);
//            info.extraBoneInfo = ReadExtraBoneInfo(reader);
//            m_animationInfo.Add(prefab, info);
//            AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader);
//            file.Close();
//#elif UNITY_IPHONE
//		    path = "file://" + Application.dataPath +"/Raw/AnimationTexture/";
//		    WWW w = new WWW(path + prefab.name + ".bytes");
//		    //wwwLoad(path + "/boneTexture/" + prefab.name + ".aniData", SetupAniInfo);
//		    while (!w.isDone){}
//		    //if (w.error)
//		    Debug.Log("This is the data path:" + path);
//		    Debug.Log(w.error);
//            BinaryReader reader = new BinaryReader(new MemoryStream(w.bytes));
//            InstanceAnimationInfo info = new InstanceAnimationInfo();
//            info.listAniInfo = ReadAnimationInfo(reader);
//            info.extraBoneInfo = ReadExtraBoneInfo(reader);
//            m_animationInfo.Add(prefab, info);
//            AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader);
//#elif UNITY_ANDROID
//            path = "jar:file://" + Application.dataPath + "!/assets/";
//            WWW w = new WWW(path + "AnimationTexture/" + prefab.name + ".bytes");
//            //wwwLoad(path + "/boneTexture/" + thisPrefab.name + ".aniData", SetupAniInfo);
//            while (!w.isDone) { }
////             BinaryReader reader = new BinaryReader(new MemoryStream(w.bytes));
////             List<AnimationInfo> listInfo = ReadAnimationInfo(reader);
////             m_animationInfo.Add(prefab, listInfo);
//            BinaryReader reader = new BinaryReader(new MemoryStream(w.bytes));
//            InstanceAnimationInfo info = new InstanceAnimationInfo();
//            info.listAniInfo = ReadAnimationInfo(reader);
//            info.extraBoneInfo = ReadExtraBoneInfo(reader);
//            m_animationInfo.Add(prefab, info);
//            AnimationInstancingMgr.Instance.ImportAnimationTexture(prefab.name, reader);
//#endif

//            return info;
//        }

        public InstanceAnimationInfo CreateAnimationInfoFromFile(string cfgName, string prefabName = null)
        {
            prefabName = cfgName;

            string tmpPath = PStr.begin().a(CLPathCfg.self.basePath).a("/").a("upgradeRes").
                             a("/priority/AnimationTexture/").a(CLPathCfg.self.platform).a("/").a(prefabName).a(".unity3d").end();

                        #if UNITY_EDITOR
            if (CLCfgBase.self.isEditMode)
            {
                tmpPath = tmpPath.Replace("/upgradeRes/", "/upgradeRes4Publish/");
            }
                        #endif
            AssetBundle assetBundel = AssetBundle.LoadFromMemory(FileEx.readNewAllBytes(tmpPath));
//			Debug.Assert(assetBundel != null);
            if (assetBundel == null)
            {
                Debug.LogError("assetBundel == null");
                return(null);
            }
            TextAsset asset = assetBundel.LoadAsset(cfgName) as TextAsset;
            //			TextAsset asset =  assetBundel.mainAsset as TextAsset;
//			Debug.Assert(asset != null);
            if (asset == null)
            {
                Debug.LogError("asset == null");
                return(null);
            }
            BinaryReader          reader = new BinaryReader(new MemoryStream(asset.bytes));
            InstanceAnimationInfo info   = new InstanceAnimationInfo();
            info.listAniInfo   = ReadAnimationInfo(reader);
            info.extraBoneInfo = ReadExtraBoneInfo(reader);
            AnimationInstancingMgr.Instance.ImportAnimationTexture(prefabName, reader);
            m_animationInfo.Add(prefabName, info);

            assetBundel.Unload(false);
            return(info);
        }
        private InstanceAnimationInfo CreateAnimationInfoFromFile(string pFileName)
        {
            Debug.Assert(!string.IsNullOrEmpty(pFileName));
            string    path  = "AnimationTexture/" + pFileName;
            TextAsset tdata = Resources.Load <TextAsset>(path);

            if (tdata == null)
            {
                Debug.LogError("Can't load asset.path = " + path);
                return(null);
            }
            BinaryReader          reader = new BinaryReader(new MemoryStream(tdata.bytes));
            InstanceAnimationInfo info   = new InstanceAnimationInfo();

            info.paramList     = ReadParameters(reader);
            info.layerList     = ReadLayers(reader);
            info.listAniInfo   = ReadAnimationInfo(reader);
            info.extraBoneInfo = ReadExtraBoneInfo(reader);
            m_animationInfo.Add(pFileName, info);
            AnimationInstancingMgr.Instance.ImportAnimationTexture(pFileName, reader);
            reader.Close();
            Resources.UnloadAsset(tdata);
            return(info);
        }