コード例 #1
0
        /// <summary>
        /// 获取缓存中的AssetBundle
        /// </summary>
        public AssetBundle GetAssetBundleCache(string bundleName)
        {
            if (!BundleCacheExist(bundleName))
            {
                return(null);
            }
            MyLoadedAssetBundle loadedBundle = m_LoadedAssetBundles [bundleName];

            loadedBundle.assetBundleRefCount++;

            return(loadedBundle.assetBundle);
        }
コード例 #2
0
        /// <summary>
        /// 将assetbundle加入缓存中
        /// </summary>
        public void AddBundleIntoCache(string bundleName, AssetBundle bundle)
        {
            Debug.LogFormat("Add bundle {0} into cache", bundleName);

            if (m_LoadedAssetBundles.ContainsKey(bundleName))
            {
                string error = string.Format("there is already a loaded bundle named {0} in loading, please don't over load asset bundle", bundleName);
                Debug.LogError(error);
                return;
            }
            MyLoadedAssetBundle myLoadedBundle = new MyLoadedAssetBundle(bundle);

            m_LoadedAssetBundles.Add(bundleName, myLoadedBundle);
            Debug.Log(bundleName + "引用计数+1:" + (m_LoadedAssetBundles [bundleName].assetBundleRefCount).ToString());
        }