コード例 #1
0
ファイル: UIFrame_Res.cs プロジェクト: jesenzhang/GameBase
        private static void BeforeInit()
        {
            //prev atlas
            AtlasData ad = null;

            tempAtlasList = new List <AtlasData>();
            for (int i = 0, count = atlasList.Count; i < count; i++)
            {
                ad = atlasList[i];
                if (ad != null && ad.referenceNum > 0)
                {
                    tempAtlasList.Add(ad);
                }
            }

            UnloadData uld;

            for (int i = 0, count = unloadList.Count; i < count; i++)
            {
                uld = unloadList[i];
                if (uld != null && uld.count > 0)
                {
                    ResLoader.RemoveAssetCacheByName(uld.data.atlasName);
                }
            }

            tempTextureList = new List <TextureData>();
            TextureData td = null;

            //prev texture
            for (int i = 0, count = textureList.Count; i < count; i++)
            {
                td = textureList[i];
                if (td != null && td.referenceNum > 0)
                {
                    tempTextureList.Add(td);
                }
            }

            UnloadTexData ultd = null;

            for (int i = 0, count = unloadTexList.Count; i < count; i++)
            {
                ultd = unloadTexList[i];
                if (ultd != null && ultd.count > 0)
                {
                    ResLoader.RemoveAssetCacheByName(ultd.data.textureName, false, false);
                }
            }
        }
コード例 #2
0
ファイル: UIFrame_Res.cs プロジェクト: jesenzhang/GameBase
        private static void RemoveTexture(int index)
        {
            bool dirtyRemove = false;

            if (index < 0)
            {
                dirtyRemove = true;
                index       = -index - 1;
            }

            if (dirtyRemove)
            {
                if (oldIndexTextureName == null)
                {
                    return;
                }
                if (index < 0 || index >= oldIndexTextureName.Count)
                {
                    Debugger.LogError("remove ui texture error->" + index);
                    return;
                }

                string name = oldIndexTextureName[index];
                ResLoader.RemoveAssetCacheByName(name, false, false);
            }
            else
            {
                if (index < 0 || index >= textureList.Count)
                {
                    Debugger.LogError("remove ui texture error->" + index);
                    return;
                }

                TextureData data = textureList[index];
                data.referenceNum--;
                Debug.LogError("remove atlas->" + data.textureName + "^" + data.referenceNum);

                if (data.referenceNum <= 0)
                {
                    UnloadTexData unloadData = unloadTexList[index];
                    unloadData.index = (short)index;
                    unloadData.count = 1;
                }
            }
        }
コード例 #3
0
ファイル: UIFrame_Res.cs プロジェクト: jesenzhang/GameBase
        private static void RequestTexture(short index, System.Action callback)
        {
            if (index < 0 || index >= textureList.Count)
            {
                Debugger.LogError("request texture is invalid->" + index);
                return;
            }


            TextureData data = textureList[index];

            if (data.texture != null)
            {
                if (data.referenceNum < 0)
                {
                    data.referenceNum = 0;
                }
                data.referenceNum++;
                if (callback != null)
                {
                    callback();
                }
                return;
            }

            if (index < 0)
            {
                return;
            }

            string name;

            if (!textureIndexToName.TryGetValue(index, out name))
            {
                return;
            }
            string destName;
            string path;
            int    size;
            bool   encrypt;

            Example.VersionFile.Type fileType;
            ResUpdate.GetLoadDetails(name, out destName, out path, out size, out encrypt, out fileType);
            if (path == null || path == "")
            {
                Debugger.LogError("ui texture is null->" + name);
                return;
            }

            if (!loadTextureCallDic.ContainsKey(index))
            {
                loadTextureCallDic.Add(index, new List <System.Action>());
            }

            List <System.Action> list = loadTextureCallDic[index];

            list.Add(callback);
            UnloadTexData ulData = unloadTexList[index];

            if (ulData.count >= 0)
            {
                ulData.count = -1;
            }
            if (list.Count == 1)
            {
                ResLoader.LoadByPath(name, destName, path, fileType, size, (asset, param) =>
                {
                    if (param == null)
                    {
                        return;
                    }

                    Texture tex = (Texture)asset;
                    ProcessTexture(tex, index);
                }, index);
            }
        }