protected virtual void _loadImp(int priority = 0, bool progress = false, uint retryCount = 0) { ResourceLoaderManager loaderManager = ResourceLoaderManager.sharedInstance(); RFLoader newLoader = loaderManager.getLoader(url, id); if (newLoader != loader && loader != null) { loader.removeEventListener(EventX.COMPLETE, loadComplete); loader.removeEventListener(EventX.FAILED, failedLoad); if (progress) { loader.removeEventListener(EventX.PROGRESS, progressHandle); } } loader = newLoader; if (retryCount > 0) { loader.autoRetry = true; loader.autoTryLimit = retryCount; } loader.checkProgress = progress; loader.addEventListener(EventX.COMPLETE, loadComplete); loader.addEventListener(EventX.FAILED, failedLoad); if (progress) { loader.addEventListener(EventX.PROGRESS, progressHandle); } loaderManager.queue(loader, priority); }
public static ResourceLoaderManager sharedInstance() { if (ins == null) { ins = new ResourceLoaderManager(); } return(ins); }
/// <summary> /// 停止加载过程(其它不变); /// </summary> public void stop() { if (loader != null) { ResourceLoaderManager.sharedInstance().unQueue(loader); loader.cancel(); } if (_status != AssetState.READY) { _status = AssetState.FAILD; } }
public AssetsManager() { if (_instance != null) { throw new Exception(); } _loaderManager = ResourceLoaderManager.sharedInstance(); regist <PrefabAssetResource>(LoaderXDataType.PREFAB); regist <PrefabAssetResource>(LoaderXDataType.SPRITE); regist <InnerAssetResource>(LoaderXDataType.RESOURCE); }
public void __dispose() { if (loader != null) { loader.removeEventListener(EventX.COMPLETE, loadComplete); loader.removeEventListener(EventX.FAILED, failedLoad); ResourceLoaderManager.sharedInstance().dispose(loader); loader.dispose(); loader = null; } if (_data != null) { //todo data; } _status = AssetState.NONE; this.simpleDispatch(EventX.DISPOSE); _clear(); _disposed = true; }
/// <summary> /// 加入资源引用计数; /// </summary> /// <returns></returns> public int release() { if (--_reference < 1) { _reference = 0; //当前状态在加载,并且 还没有推送到浏览器; if (_status == AssetState.LOADING) { if (ResourceLoaderManager.sharedInstance().unQueue(loader)) { _status = AssetState.NONE; } else if (loader != null) { loader.cancel(true); _status = AssetState.FAILD; } } AutoReleasePool.add(this); } return(_reference); }