Exemplo n.º 1
0
        /// <summary>
        /// Dispose是有引用检查的, DoDispose一般用于继承重写
        /// </summary>
        public void Dispose()
        {
            if (DisposeEvent != null)
            {
                DisposeEvent();
            }
            DisposeEvent = null;

            if (!IsForceNew)
            {
                bool bRemove = LoaderCache.RemoveLoader(this);
                if (!bRemove)
                {
                    Debuger.LogWarning("[{0}:Dispose], No Url: {1}, Cur RefCount: {2}", GetType().Name, AssetPath, RefCount);
                }
            }

            if (IsCompleted)
            {
                DoDispose();
            }
            else
            {
                // 未完成,在OnFinish时会执行DoDispose
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 释放资源,减少引用计数
        /// </summary>
        public virtual void Release()
        {
            if (IsReadyDisposed && Debug.isDebugBuild)
            {
                this.LogWarning("[{0}]Too many dipose! {1}, Count: {2}", GetType().Name, this.AssetPath, RefCount);
            }

            RefCount--;
            if (RefCount <= 0)
            {
                // 加入队列,准备Dispose
                LoaderCache.AddUnusedLoader(this);

                IsReadyDisposed = true;
                OnReadyDisposed();
            }
        }
Exemplo n.º 3
0
 private void Update()
 {
     // loader gc
     LoaderCache.CheckGcCollect();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Load the specified assetBundlePath, assetPath, loadMode, callback, forceCreateNew and initArgs.
 /// 加载 assetBundle 时: assetPath 为null或者""
 /// 加载 assetBundle中的asset 时: assetBundlePath和assetPath都要填
 /// 加载 非assetBundle中的asset 时: assetBundlePath 为null或者""
 /// </summary>
 public static T Load <T>(string assetBundlePath, string assetPath, LoadMode loadMode = LoadMode.Async, LoaderCallback callback = null,
                          bool forceCreateNew = false, params object[] initArgs) where T : BaseLoader, new()
 {
     return(LoaderCache.AutoNew <T>(assetBundlePath, assetPath, loadMode, callback, forceCreateNew, initArgs));
 }
Exemplo n.º 5
0
 // 清除所有加载器,慎用!
 public void Clear()
 {
     LoaderCache.ClearCaches();
 }