public void Load() { loading = true; this.www = null; if (CMisc.isLegalNumber(name) && Global.publishConfig.isDebugOpen) { //CGameHintUI.Show(ErrorCodes.GetTextFormat(ErrorCodes.INVALID_LOAD_PATH, name)); return; } if (!string.IsNullOrEmpty(name) && name != "empty") { this.www = new WWW(CDirectory.MakeFullWWWPath(name)); } }
public T CreateInstance <T>(string filename, IRenderObject parent, bool unload, params object[] args) where T : IRenderObject { IRenderResource resource; filename = filename.ToLower(); if (CMisc.isLegalNumber(filename)) { LOG.LogError(Localization.Format("INVALID_LOAD_PATH", filename)); } if (parent != null && parent.GetOwner() != null) { if (parent.GetOwner().unload_asset) { unload = parent.GetOwner().unload_asset; } } if (idle.TryGetValue(filename, out resource)) { idle.Remove(filename); if (resource.complete) { complete.Add(filename, resource); } else { loading.Add(filename, resource); } //LOG.Debug( "***** get resource {0} from idle, linger {1}s", filename, Time.realtimeSinceStartup - resource.idle_time ); } else if (!loading.TryGetValue(filename, out resource)) { if (!complete.TryGetValue(filename, out resource)) { resource = new IRenderResource(filename, this); resource.unload_asset = unload; loading.Add(resource.name, resource); Cookie cookie = GetCookie(filename); ++cookie.create; } } if (resource == null) { return(null); } return(resource.CreateInstance <T>(parent, args)); }
public void Create() { this.complete = true; if (this.www != null) { try { if (this.www.bytesDownloaded > 0 && string.IsNullOrEmpty(www.error)) { if (this.name.EndsWith(".txt") && !string.IsNullOrEmpty(this.www.text)) { this.text = new StringBuilder(this.www.text); } // this.movie = this.www.movie; this.asset_bundle = this.www.assetBundle; } } catch (Exception e) { LOG.Debug(name); LOG.Debug(e.ToString()); } this.www.Dispose(); this.www = null; } if (CMisc.isLegalNumber(name)) { return; } OnCreate(this.asset_bundle); for (int i = 0; i < insts.Count; ++i) { insts[i].Create(); } if (this.unload_asset && this.asset_bundle != null) { this.asset_bundle.Unload(false); //LOG.Debug( "=> unload asset {0} after create", name ); } }