コード例 #1
0
ファイル: ABAudio.cs プロジェクト: iningwei/CFX-DEV
        /// <summary>
        /// name不带后缀,不带前缀
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static AudioClip Load(string name)
        {
            AudioClip   clip = null;
            AssetBundle ab   = LoadAB(name);

            clip = ab.LoadAsset(name) as AudioClip;
            ab.Unload(false);
            if (clip == null)
            {
                Debug.LogError("load audioclip " + name + " null");
            }
            AudioRes res = new AudioRes(name, clip);

            EventDispatcher.Instance.DispatchEvent(EventID.OnABResLoaded, res);
            return(clip);
        }
コード例 #2
0
ファイル: ABManager.cs プロジェクト: iningwei/CFX-DEV
        private void onABResLoaded(string evtId, object[] paras)
        {
            Res res = paras[0] as Res;


            if (res is WindowRes)
            {
                WindowRes wRes = res as WindowRes;
                ResCacheDic[ABType.Window][wRes.resName] = wRes;


                //----->可视化显示
                //var older = windowResList.Find(a => a.resName == wRes.resName);
                //if (older != null)
                //{
                //    older = wRes;
                //}
                //else
                //{
                //    windowResList.Add(wRes);
                //}
                //TODO:用上述方法,不知道是什么原因导致的inspector面板上ResObj没有显示出来

                var older = ABManagerMono.Instance.windowResList.Find(a => a.resName == wRes.resName);
                if (older != null)
                {
                    ABManagerMono.Instance.windowResList.Remove(older);
                }

                ABManagerMono.Instance.windowResList.Add(wRes);

                GameObject obj = wRes.resObj as GameObject;
                fillMatTexHolder(obj);
                this.addDestroyNotice(obj);
            }
            else if (res is EffectRes)
            {
                EffectRes effRes = res as EffectRes;
                ResCacheDic[ABType.Effect][effRes.resName] = effRes;

                //可视化处理
                var older = ABManagerMono.Instance.effectResList.Find(a => a.resName == effRes.resName);
                if (older != null)
                {
                    ABManagerMono.Instance.effectResList.Remove(older);
                }
                ABManagerMono.Instance.effectResList.Add(effRes);



                GameObject obj = effRes.resObj as GameObject;
                fillMatTexHolder(obj);
                this.addDestroyNotice(obj);
            }
            else if (res is OtherPrefabRes)
            {
                OtherPrefabRes opRes = res as OtherPrefabRes;
                ResCacheDic[ABType.OtherPrefab][opRes.resName] = opRes;

                //可视化处理
                var older = ABManagerMono.Instance.opResList.Find(a => a.resName == opRes.resName);
                if (older != null)
                {
                    ABManagerMono.Instance.opResList.Remove(older);
                }
                ABManagerMono.Instance.opResList.Add(opRes);



                GameObject obj = opRes.resObj as GameObject;
                fillMatTexHolder(obj);
                this.addDestroyNotice(obj);
            }
            else if (res is SpriteRes)
            {
                SpriteRes sRes = res as SpriteRes;
                ABManagerMono.Instance.spriteResList.Add(sRes);
                ResCacheDic[ABType.Sprite][sRes.resName] = sRes;
            }
            else if (res is TextureRes)
            {
                TextureRes tRes = res as TextureRes;
                ABManagerMono.Instance.texResList.Add(tRes);
                ResCacheDic[ABType.Texture][tRes.resName] = tRes;
            }
            else if (res is AudioRes)
            {
                AudioRes aRes = res as AudioRes;
                ABManagerMono.Instance.audioResList.Add(aRes);
                ResCacheDic[ABType.Audio][aRes.resName] = aRes;
            }
        }