Beispiel #1
0
    protected static bool UnloadAssetBundleInternal(string assetBundleName, bool unloadAllLoadedObjects, string origin)
    {
        LoadedAssetBundle bundle = GetLoadedAssetBundle(assetBundleName);

        if (bundle == null)
        {
            return(false);
        }

        bundle.m_ReferencedCount--;
        if (bundle.needUnload == false)
        {
            bundle.m_ReferencedCount = 1;
        }

        if (bundle.m_ReferencedCount == 0)
        {
            //bundle.m_AssetBundle.Unload(true);
            bundle.Dispose(unloadAllLoadedObjects);
            m_LoadedAssetBundles.Remove(assetBundleName);
#if DEBUG_ASSETBUNDLE
            Debug.LogFormat("[AssetBundleManager] delete {0}, ref:{1}, origin:{2}", assetBundleName, bundle.m_ReferencedCount, origin);
#endif
        }
#if DEBUG_ASSETBUNDLE
        else
        {
            Debug.LogFormat("[AssetBundleManager] delete {0}, ref:{1}, origin:{2}", assetBundleName, bundle.m_ReferencedCount, origin);
        }
#endif

        return(true);
    }
Beispiel #2
0
    public virtual void UnLoadUnReference()
    {
        if (m_Cache.Count <= 0)
        {
            return;
        }

        foreach (KeyValuePair <int, LoadedAssetBundle> kvp in m_Cache)
        {
            LoadedAssetBundle sab = kvp.Value;
            if (sab != null)
            {
                if (sab.RefCount <= 0)
                {
                    //Debug.Log("<color=blue> UnLoadUnReference: " + kvp.Key + "\n" + "</color>");
                    //if (sab.bundleName.Contains("data/sound/sound/matchvioce/cv_a"))
                    //{
                    //    int jjj = 0;
                    //}
                    sab.Dispose();
                    m_Removes.Add(kvp.Key);
                }
            }
        }

        for (int i = 0; i < m_Removes.size; ++i)
        {
            m_Cache.Remove(m_Removes[i]);
        }
        m_Removes.Clear();
    }
Beispiel #3
0
 static public int Dispose(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         LoadedAssetBundle self = (LoadedAssetBundle)checkSelf(l);
         System.Boolean    a1;
         checkType(l, 2, out a1);
         self.Dispose(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Beispiel #4
0
    public virtual void UnLoadBundle(int nBundleId, bool unloadAllLoadedObjects)
    {
        LoadedAssetBundle bundle = null;

        if (m_Cache.TryGetValue(nBundleId, out bundle))
        {
            if (unloadAllLoadedObjects)
            {
                //Debug.Log("<color=yellow> UnLoadBundle: " + name + " unloadAllLoadedObjects: " + unloadAllLoadedObjects + "\n" + "</color>");
                bundle.Dispose();
                m_Cache.Remove(nBundleId);
            }
            else
            {
                bundle.UnCount();
                //if (bundle.RefCount <= 0)
                //{
                //    bundle.Dispose();
                //    m_Cache.Remove(name);
                //}
            }
        }
    }