コード例 #1
0
        async void LoadResAsync(EABType abType, string bundleName)
        {
            var tmpResMgr = Game.ResourcesMgr;

            await tmpResMgr.LoadBundleByTypeAsync(abType, bundleName);

            if (mIsRelease)
            {
                tmpResMgr.UnLoadBundleByType(abType, bundleName);
                return;
            }

            //Logger.Log($"成功加载bundle -> {bundleName} 已成功 -> {mLoadedResCount} 需加载 -> {mNeedLoadResCount}");
            //已加载的bundle记录
            List <string> tmpBundleNameList = null;

            if (!mAbType2NameLoadedResDict.TryGetValue((int)abType, out tmpBundleNameList))
            {
                tmpBundleNameList = new List <string>();
                mAbType2NameLoadedResDict.Add((int)abType, tmpBundleNameList);
            }

            tmpBundleNameList.Add(bundleName);

            //
            ++mLoadedResCount;

            if (mLoadedResCount >= mNeedLoadResCount)
            {
                mLoadedHandle?.Invoke();
                mLoadedHandle = null;
            }
        }
コード例 #2
0
ファイル: PoAttachGoBase.cs プロジェクト: dqtoy/ActDemo
        //释放资源
        void ReleaseRes(EABType resType = EABType.Invalid, string resName = null)
        {
            if (null != mGameObject)
            {
                Game.ResourcesMgr.ResPool.Despawn(EABType.Invalid != resType ? resType : this.ResType,
                                                  null != resName ? resName : this.ResName, mGameObject);

                mGameObject = null;
            }
        }
コード例 #3
0
        public GameObject Spawn(EABType resType, string goName)
        {
            GameObject     tmpGo     = null;
            GameObjectPool tmpGoPool = null;

            if (mABType2GoPoolDict.TryGetValue(resType, out tmpGoPool))
            {
                tmpGo = tmpGoPool.Spawn(goName);
            }

            return(tmpGo);
        }
コード例 #4
0
        public void AddPreLoadRes(EABType type, string bundleName)
        {
            List <string> tmpBundleNameList = null;

            if (!mAbType2NameDict.TryGetValue((int)type, out tmpBundleNameList))
            {
                tmpBundleNameList = new List <string>();
                mAbType2NameDict.Add((int)type, tmpBundleNameList);
            }

            tmpBundleNameList.Add(bundleName);
        }
コード例 #5
0
        public void Despawn(EABType resType, string goName, GameObject go)
        {
            GameObjectPool tmpGoPool = null;

            if (!mABType2GoPoolDict.TryGetValue(resType, out tmpGoPool))
            {
                GameObject tmpGo = new GameObject(resType.ToString());
                tmpGo.transform.SetParent(mRootGo.transform, false);
                tmpGoPool = new GameObjectPool(tmpGo);
                mABType2GoPoolDict.Add(resType, tmpGoPool);
            }

            tmpGoPool.Despawn(goName, go);
        }
コード例 #6
0
        void ReleaseRes()
        {
            if (EABType.Invalid != mResType && !string.IsNullOrEmpty(mResName))
            {
                Game.ResourcesMgr.UnLoadBundleByType(mResType, mResName);
                mResType = EABType.Invalid;
                mResName = string.Empty;
            }

            if (null != mImage)
            {
                mImage.sprite = null;
                Utility.GameObj.SetActive(mImage, false);
            }
        }
コード例 #7
0
        public void ClearByType(EABType eABType)
        {
            GameObjectPool tmpGoPool = null;

            if (mABType2GoPoolDict.TryGetValue(eABType, out tmpGoPool))
            {
                tmpGoPool.Clear((name, count) =>
                {
                    for (int i = 0; i < count; ++i)
                    {
                        mResMgr.UnLoadBundleByType(eABType, name);
                    }
                });

                mABType2GoPoolDict.Remove(eABType);
            }
        }
コード例 #8
0
        //异步加载
        async void LoadResAsync(EABType type, string name)
        {
            await Game.ResourcesMgr.LoadBundleByTypeAsync(type, name);

            if (type != mResType || !name.Equals(mResName))
            {
                Game.ResourcesMgr.UnLoadBundleByType(type, name);
                return;
            }

            if (mIsReleased)
            {
                ReleaseRes();
                return;
            }

            OnResLoaded();
        }
コード例 #9
0
        public void LoadByAbType(EABType type, string name, Image image, Action loadedHandle = null, bool async = true)
        {
            mIsReleased = false;

            mResType      = type;
            mResName      = name;
            mImage        = image;
            mLoadedHandle = loadedHandle;
            Utility.GameObj.SetActive(image, false);

            if (async)
            {
                LoadResAsync(type, name);
            }
            else
            {
                LoadResSync(type, name);
            }
        }
コード例 #10
0
ファイル: PoAttachGoBase.cs プロジェクト: dqtoy/ActDemo
        //重新异步加载资源
        private async void ReloadResAsync()
        {
            EABType tmpResType = ResType;
            string  tmpResName = ResName;
            await Game.ResourcesMgr.LoadBundleByTypeAsync(tmpResType, tmpResName);

            GameObject tmpGo = Game.ResourcesMgr.GetAssetByType <GameObject>(tmpResType, tmpResName);

            if (null == tmpGo)
            {
                return;
            }

            tmpGo = Hotfix.Instantiate(tmpGo);
            InitGameObject(tmpGo);

            if (mIsInvalid)
            {
                ReleaseRes(tmpResType, tmpResName);
                return;
            }

            OnResLoaded();
        }
コード例 #11
0
 public async Task LoadBundleByTypeAsync(EABType abType, string abName)
 {
     await ResMgrBase.Instance.LoadBundleAsync(GetBundleNameByType(abType, abName));
 }
コード例 #12
0
 public void LoadBundleByType(EABType type, string abName)
 {
     ResMgrBase.Instance.LoadBundle(GetBundleNameByType(type, abName));
 }
コード例 #13
0
 public K GetAssetByType <K>(EABType abType, string bundleName, string assetName) where K : class
 {
     return(ResMgrBase.Instance.GetAsset <K>(GetBundleNameByType(abType, bundleName), assetName));
 }
コード例 #14
0
 public static string GetBundleNameByType(EABType type, string name)
 {
     return(string.Format(ABType2Path[(int)type], name));
 }
コード例 #15
0
ファイル: ResourcesManager.cs プロジェクト: lllllgb/AosUnity
 public void LoadBundleByType(EABType type, string abName)
 {
     LoadBundle(ResourcesHelper.GetBundleNameByType(type, abName));
 }
コード例 #16
0
ファイル: ResourcesManager.cs プロジェクト: lllllgb/AosUnity
 public async Task LoadBundleByTypeAsync(EABType abType, string abName)
 {
     await LoadBundleAsync(ResourcesHelper.GetBundleNameByType(abType, abName));
 }
コード例 #17
0
 //同步加载
 void LoadResSync(EABType type, string name)
 {
     Game.ResourcesMgr.LoadBundleByType(type, name);
     OnResLoaded();
 }
コード例 #18
0
ファイル: ResourcesManager.cs プロジェクト: lllllgb/AosUnity
 public K GetAssetByType <K>(EABType abType, string bundleName) where K : class
 {
     return(GetAsset <K>(ResourcesHelper.GetBundleNameByType(abType, bundleName), bundleName));
 }