Пример #1
0
        uint ReleaseOne(string abName)
        {
            AssetBundleInstance assetBundleInstance = null;

            cache.TryGetValue(abName, out assetBundleInstance);

            if (assetBundleInstance == null)
            {
                Debug.LogErrorFormat("AssetBundleManagar cache 中没有 {0}, id {1} ", abName, GetInstanceID());
                return(0);
            }
            //引用计数减 1
            if (assetBundleInstance.Release() == 0)
            {
                assetBundleInstance.Unload();
                cache.Remove(abName);
                if (debugLog)
                {
                    Debug.LogErrorFormat("释放 {0}", abName);
                }
                return(0);
            }
            if (debugLog)
            {
                Debug.LogErrorFormat("引用减 1 {0} ReferenceCount {1}", abName, assetBundleInstance.GetReferenceCount());
            }

            return(assetBundleInstance.GetReferenceCount());
        }
Пример #2
0
        uint ReleaseOne(string abName)
        {
            //1.检测正在加载中的
            if (curAssetBundleLoader != null)
            {
                if (curAssetBundleLoader.name.Equals(abName))
                {
                    curAssetBundleLoader.Release();
                    return(curAssetBundleLoader.referenceCount);
                }
            }
            //2. 检查 是否在等待队列里
            AssetBundleLoader[] waitings = waiting.ToArray();
            AssetBundleLoader   curWaitingAssetBundleLoader;

            for (int i = 0; i < waitings.Length; i++)
            {
                curWaitingAssetBundleLoader = waitings[i];
                if (curWaitingAssetBundleLoader.name.Equals(abName))
                {
                    curWaitingAssetBundleLoader.Release();
                    return(curWaitingAssetBundleLoader.referenceCount);
                }
            }
            //3.检测缓存
            AssetBundleInstance assetBundleInstance = null;

            cache.TryGetValue(abName, out assetBundleInstance);

            if (assetBundleInstance == null)
            {
                Debug.LogErrorFormat("AssetBundleManagar cache 中没有 {0} ", abName);
                return(0);
            }
            //引用计数减 1
            if (assetBundleInstance.Release() == 0)
            {
                assetBundleInstance.Unload();
                cache.Remove(abName);
                if (debugLog)
                {
                    Debug.LogErrorFormat("释放 {0}", abName);
                }
                return(0);
            }
            if (debugLog)
            {
                Debug.LogErrorFormat("引用减 1 {0} ReferenceCount {1}", abName, assetBundleInstance.GetReferenceCount());
            }

            return(assetBundleInstance.GetReferenceCount());
        }