예제 #1
0
        private AssetAssociate GetAssociate(string path)
        {
            AssetAssociate pathassociate = null;

            if (mAssociatelist.TryGetValue(path, out pathassociate))
            {
                return(pathassociate);
            }
            return(null);
        }
예제 #2
0
        public void UnloadAssets(bool unloadAll)
        {
            //TODO:这里有死循环,明日来后要查一查!!!!!!!!!!
            Dictionary <string, int> safeCount = new Dictionary <string, int>();

            while (mRecyAssets.Count > 0)
            {
                AssetData asset = mRecyAssets[0];
                mRecyAssets.RemoveAt(0);
                if (asset == null)
                {
                    continue;
                }

                AssetAssociate aa = GetAssociate(asset.url);
                if (aa != null && aa.HasAssociateInMemory)
                {
                    int nCount = 0;
                    safeCount.TryGetValue(asset.url, out nCount);
                    if (nCount < 5)
                    {
                        //确保资源删除时,被访问不要超过5次,5次遍历列表失败,此资源强制删除
                        mRecyAssets.Add(asset);
                        if (safeCount.ContainsKey(asset.url))
                        {
                            safeCount[asset.url]++;
                        }
                        else
                        {
                            safeCount.Add(asset.url, 1);
                        }
                        continue;
                    }
                }
                if (asset != null && !asset.IsUnLoaded)
                {
                    ChangeAssetState(asset, false);
                    asset.UnLoad(true);
                    mAssetInMemory.Remove(asset.url);
                    mRecycleLookUP.Remove(asset.url);
                }
            }
        }
예제 #3
0
        //记录引用
        public void RecordAssociate(string url, string[] depends)
        {
            AssetAssociate aa = null;

            url = AssetUtility.GetRealPath(url);

            if (depends != null)
            {
                for (int i = 0; i < depends.Length; ++i)
                {
                    string tdp = AssetUtility.GetRealPath(depends[i]);
                    if (!mAssociatelist.TryGetValue(tdp, out aa))
                    {
                        aa     = new AssetAssociate();
                        aa.url = tdp;
                        mAssociatelist.Add(tdp, aa);
                    }
                    aa.SetAssociate(url, aa.GetAAState(url));
                }
            }
        }