Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 public AssetsLoad(string assetBundleName)
 {
     if (EditorAssetLoad.LocalLoadModel)
     {
         editorAssetLoad = EditorAssetLoad.Take(assetBundleName);
     }
     else
     {
         assetBundleLoad = AssetBundleLoad.Take(assetBundleName);
     }
 }
Ejemplo n.º 3
0
 public void UnLoad()
 {
     if (EditorAssetLoad.LocalLoadModel)
     {
         EditorAssetLoad.Put(editorAssetLoad);
         editorAssetLoad = null;
     }
     else
     {
         AssetBundleLoad.Put(assetBundleLoad);
         assetBundleLoad = null;
     }
 }
Ejemplo n.º 4
0
        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--;
            }
        }