コード例 #1
0
ファイル: AssetBundleLoad.cs プロジェクト: cofdream/Null
        public static AssetBundleLoad Take(string assetBundleName)
        {
            AssetBundleLoad assetBundleLoad;

            if (allAssetBundleDic.TryGetValue(assetBundleName, out assetBundleLoad) == false)
            {
                //todo 验证是ab包名正确性

                assetBundleLoad = new AssetBundleLoad();
                allAssetBundleDic.Add(assetBundleName, assetBundleLoad);

                assetBundleLoad.referenceCount  = 0;
                assetBundleLoad.loadState       = LoadState.NotLoad;
                assetBundleLoad.assetBundleName = assetBundleName;
                assetBundleLoad.allAsset        = new Dictionary <string, Object>();

                assetBundleLoad.referenceCount++;
                return(assetBundleLoad);
            }
            else
            {
                assetBundleLoad.referenceCount++;
                return(assetBundleLoad);
            }
        }
コード例 #2
0
ファイル: AssetsLoad.cs プロジェクト: cofdream/Null
 public AssetsLoad(string assetBundleName)
 {
     if (EditorAssetLoad.LocalLoadModel)
     {
         editorAssetLoad = EditorAssetLoad.Take(assetBundleName);
     }
     else
     {
         assetBundleLoad = AssetBundleLoad.Take(assetBundleName);
     }
 }
コード例 #3
0
ファイル: AssetsLoad.cs プロジェクト: cofdream/Null
 public void UnLoad()
 {
     if (EditorAssetLoad.LocalLoadModel)
     {
         EditorAssetLoad.Put(editorAssetLoad);
         editorAssetLoad = null;
     }
     else
     {
         AssetBundleLoad.Put(assetBundleLoad);
         assetBundleLoad = null;
     }
 }
コード例 #4
0
ファイル: AssetBundleLoad.cs プロジェクト: cofdream/Null
        public static void Put(AssetBundleLoad assetBundleLoad)
        {
            if (assetBundleLoad.referenceCount == 1)
            {
                assetBundleLoad.referenceCount = 0;

                foreach (var assetBundleLoadDeoend in assetBundleLoad.assetBundleLoadDependencies)
                {
                    Put(assetBundleLoadDeoend);
                }

                assetBundleLoad.loadState = LoadState.Unload;
                assetBundleLoad.assetBundle.Unload(true);
                assetBundleLoad.assetBundle = null;
                assetBundleLoad.allAsset.Clear();
            }
            else
            {
                assetBundleLoad.referenceCount--;
            }
        }