public void Unload(bool unloadAllLoadedObjects = true)
 {
     if (_ab == null)
     {
         return;
     }
     _ab?.Unload(unloadAllLoadedObjects);
     _ab = null;
 }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="swfUri"></param>
        /// <returns></returns>
        public bool unloadSWF(string swfUri)
        {
            if (!bundles.ContainsKey(swfUri))
            {
                return(false);
            }
            IAssetBundle bundle = bundles[swfUri];

            bundle.Unload(true);
            return(true);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="swfUri"></param>
        /// <param name="useAssetBundle"></param>
        /// <returns></returns>
        internal SwfAssetContext loadSWF(string swfUri, IAssetBundle useAssetBundle)
        {
            if (swfUri.EndsWith(".swf"))
            {
                swfUri = swfUri.Substring(0, swfUri.IndexOf(".swf"));
            }
            if (contextCache.ContainsKey(swfUri))
            {
                return(contextCache[swfUri]);
            }
            string uri = swfUri;

            if (useAssetBundle == null)
            {
                return(null);
            }
            TextAsset swfInfoAsset = useAssetBundle.Load <TextAsset>(uri);

            if (swfInfoAsset == null)
            {
                Debug.LogError("MovieClip() Invalid asset url '" + swfUri + "' actual url loaded '" + uri + "'");
                return(null);
            }
            string  texuri  = swfUri + "_tex";
            Texture texture = useAssetBundle.Load <Texture>(texuri);

            if (texture == null)
            {
                Debug.Log(string.Concat("Failed to load texture: ", texuri, " from bundle: ", useAssetBundle));
                return(null);
            }
            Material material = new Material(baseBitmapShader)
            {
                color = Color.white,
                name  = texuri
            };

            texture.name         = texuri;
            material.mainTexture = texture;

            SwfAssetContext context = _loadFromTextAsset(swfInfoAsset, uri, useAssetBundle, new Vector2(texture.width, texture.height));

            if (context != null)
            {
                context.texture  = texture;
                context.material = material;
            }

            useAssetBundle.Unload(uri);
            return(context);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        public virtual void UnLoadAsset(string path)
        {
            if (beginLoad)
            {
                throw new ArgumentException("Loading entity, can't add new resources!");
            }
            IAssetBundle asset = assets[path];

            if (asset != null)
            {
                if (assetLoaders.ContainsKey(asset.Parameter.LoadType))
                {
                    assetLoaders[asset.Parameter.LoadType].RemoveAsset(asset);
                }
                asset.Unload(true);
            }
        }
        private void UnloadAssetBundlePrivate(IAssetBundle assetBundle, bool unloadAllLoadedObjects)
        {
            if (!m_CreatedAssetBundles.Remove(assetBundle.Name))
            {
                Debug.LogWarning($"AssetBundle '{assetBundle.Name}' is not loaded, you can not unload it.");
                return;
            }

            assetBundle.Unload(unloadAllLoadedObjects);
            LogMessage("Unload AssetBundle: '", assetBundle.Name, "', unloadAllLoadedObjects: ", unloadAllLoadedObjects);

            for (int i = 0; i < assetBundle.Dependencies.Length; i++)
            {
                IAssetBundle dep = assetBundle.Dependencies[i];
                dep.DecreaseRef();

                if (dep.RefCount <= 0)
                {
                    UnloadAssetBundlePrivate(dep, unloadAllLoadedObjects);
                }
            }
        }
예제 #6
0
 public void Unload(bool unloadAllLoadedObjects = true)
 {
     _assetBundle?.Unload(unloadAllLoadedObjects);
     _assetBundle = null;
 }