public IAssetRequest LoadAudio(string url, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType) { if (string.IsNullOrEmpty(url)) { Debug.LogError("string.IsNullOrEmpty(url) == true"); return(null); } string text = string.Format("{0}/{1}", this.m_strBaseResDir, url); try { if (!Path.HasExtension(text)) { text = Path.ChangeExtension(text, ".mp3"); } } catch (Exception ex) { XLog.Log.Fatal(ex.Message); } text = GameResourceManager.StandardlizePath(text); GameAssetResource assetResource = this.GetAssetResource(text, assetPRIType, true); return(new GameAssetRequest(assetResource, callBackFun)); }
private void UnLoadNotUsedResource() { List <string> list = new List <string>(); foreach (KeyValuePair <string, GameAssetResource> current in this.m_dicAllAssetRes) { if (0 >= current.Value.RefCount) { list.Add(current.Key); } } for (int i = 0; i < list.Count; i++) { string key = list[i]; GameAssetResource localAssetResource = null; if (this.m_dicAllAssetRes.TryGetValue(key, out localAssetResource)) { if (localAssetResource != null) { localAssetResource.Dispose(); } this.m_dicAllAssetRes.Remove(key); } } }
public void OnUpdate() { if (this.m_allUnLoadFinishedEventHandler != null) { Resources.UnloadUnusedAssets(); Action <bool> allUnloadFinishedEventHandler = this.m_allUnLoadFinishedEventHandler; this.m_allUnLoadFinishedEventHandler = null; allUnloadFinishedEventHandler(true); } if (this.m_WWWqueue.Count > 0) { GameAssetResource localAssetResource = this.m_WWWqueue.Peek(); if (localAssetResource.IsDone) { if (!string.IsNullOrEmpty(localAssetResource.Error)) { this.m_bLoadError = true; Debug.LogError(localAssetResource.Error); } //if (this.m_allLoadFinishedEventHandler != null) //{ this.m_nSizeHasLoadedFromStart++; //} this.m_WWWqueue.Dequeue(); localAssetResource.OnDownLoadFinished(); } else if (localAssetResource.Canceled) { this.m_WWWqueue.Dequeue(); } else if (!localAssetResource.Started) { localAssetResource.BeginLoad(); } } else { if (this.m_allLoadFinishedEventHandler != null) { Action <bool> allLoadFinishedEventHandler = this.m_allLoadFinishedEventHandler; this.m_allLoadFinishedEventHandler = null; try { allLoadFinishedEventHandler(!this.m_bLoadError); } catch (Exception exception) { Debug.LogException(exception); } this.m_nSizeHasLoadedFromStart = 0; this.m_nSizeNeedToLoadFromStart = 0; } } this.UnLoadNotUsedResource(); }
public IAssetRequest LoadScene(string url, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType) { if (string.IsNullOrEmpty(url)) { Debug.LogError("string.IsNullOrEmpty(url) == true"); return(null); } string url2 = string.Format("{0}/{1}.unity3d", this.m_strBaseResDir, url); GameAssetResource assetResource = this.GetAssetResource(url2, assetPRIType, true); return(new GameAssetRequest(assetResource, callBackFun)); }
public IAssetRequest LoadTexture(string url, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType) { if (string.IsNullOrEmpty(url)) { Debug.LogError("string.IsNullOrEmpty(url) == true"); return(null); } string text = string.Format("{0}/{1}.jpg", this.m_strBaseResDir, url); text = GameResourceManager.StandardlizePath(text); GameAssetResource assetResource = this.GetAssetResource(text, assetPRIType, true); return(new GameAssetRequest(assetResource, callBackFun)); }
public IAssetRequest CreateAssetRequest(string assetUrl, List <string> dependes, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType, EnumAssetType eAssetType) { if (string.IsNullOrEmpty(assetUrl)) { Debug.LogError("string.IsNullOrEmpty(assetUrl) == true"); return(null); } assetUrl = string.Format("{0}/{1}", this.m_strBaseResDir, assetUrl); assetUrl = GameResourceManager.StandardlizePath(assetUrl); GameAssetResource assetResource = this.GetAssetResource(assetUrl, assetPRIType, true); return(new GameAssetRequest(assetResource, callBackFun)); }
public GameAssetRequest(GameAssetResource assetResource, AssetRequestFinishedEventHandler eventHandler) { if (assetResource == null) { this.m_bIsError = true; return; } this.m_localAssetResource = assetResource; this.m_localAssetResource.AddRef(this); this.m_eventHandlerAssetRequestFinished = eventHandler; if (eventHandler != null && this.m_localAssetResource.HasCallBacked) { GameResourceManager.Instance.StartCoroutine(this.DelayCallBack(eventHandler, this)); } }
public IAssetRequest LoadAtlas(string url, AssetRequestFinishedEventHandler callBackFun) { if (string.IsNullOrEmpty(url)) { Debug.LogError("string.IsNullOrEmpty(url) == true"); return(null); } string text = string.Format("{0}/{1}", this.m_strBaseResDir, url); text = Path.ChangeExtension(text, ".prefab"); text = GameResourceManager.StandardlizePath(text); GameAssetResource assetResource = this.GetAssetResource(text, true); return(new GameAssetRequest(assetResource, callBackFun)); }
protected void Dispose(bool disposing) { if (this.m_bDisposed) { return; } if (disposing) { if (this.m_localAssetResource != null) { this.m_localAssetResource.DelRef(this); this.m_localAssetResource = null; } this.m_eventHandlerAssetRequestFinished = null; } this.m_bDisposed = true; }
private GameAssetResource GetAssetResource(string url, AssetPRI assetPRIType, bool bAssetInEditor) { GameAssetResource localAssetResource = null; if (!this.m_dicAllAssetRes.TryGetValue(url, out localAssetResource)) { localAssetResource = new GameAssetResource(url); localAssetResource.IsAssetInEditor = bAssetInEditor; if (this.m_allLoadFinishedEventHandler != null) { this.m_nSizeNeedToLoadFromStart++; } this.m_WWWqueue.Enqueue(localAssetResource); this.m_dicAllAssetRes.Add(url, localAssetResource); } return(localAssetResource); }