예제 #1
0
    public void DestroyAssetBundle(string bundleName)
    {
        AssetBundleContainer assetBundleContainer = null;

        this.assetBundles.TryGetValue(bundleName, out assetBundleContainer);
        if (assetBundleContainer != null)
        {
            foreach (GameObject current in assetBundleContainer.ObjectList)
            {
                if (current != null)
                {
                    UnityEngine.Object.Destroy(current);
                }
            }
            assetBundleContainer.ObjectList.Clear();
            assetBundleContainer.Unload();
            this.assetBundles.Remove(bundleName);
        }
    }
예제 #2
0
    /// <summary>
    /// Destroys and unloads an asset bundle and all its referenced objects with
    /// the specified key.
    /// </summary>
    /// <param name='bundleName'>
    /// Bundle name.
    /// </param>
    public void DestroyAssetBundle(string bundleName)
    {
        AssetBundleContainer thisBundle = null;

        assetBundles.TryGetValue(bundleName, out thisBundle);
        if (thisBundle != null)
        {
            //Destroy all the game objects that are referencing to this bundle
            foreach (GameObject obj in thisBundle.ObjectList)
            {
                if (obj != null)
                {
                    Destroy(obj);
                }
            }
            thisBundle.ObjectList.Clear();
            thisBundle.Unload();
            assetBundles.Remove(bundleName);
        }
    }