private void Update() { if ((this.dbLoader != null) && this.dbLoader.IsDone) { Engine engine = EngineService.Engine; base.enabled = false; if (!string.IsNullOrEmpty(this.dbLoader.Error)) { string message = $"AssetBundleDatabase loading was failed. URL: {this.dbLoader.URL}, Error: {this.dbLoader.Error}"; LoggerProvider.GetLogger(this).Error(message); this.dbLoader.Dispose(); this.dbLoader = null; engine.ScheduleEvent <InvalidGameDataErrorEvent>(engine.CreateEntity("RemoteConfigLoading")); } else { this.dbLoader.Dispose(); this.dbLoader = null; AssetBundleDatabaseComponent component = new AssetBundleDatabaseComponent { AssetBundleDatabase = this.DeserializeDatabase(this.dbLoader.Bytes) }; this.dbEntity.AddComponent(component); base.Complete(); } } }
private void DisposeWWWLoader() { if (this.wwwLoader != null) { this.wwwLoader.Dispose(); this.wwwLoader = null; } }
static IEnumerator DoLoad(WWWLoader loader, WWW w3) { #if UNITY_EDITOR yield return(null); #endif yield return(w3); loader.OnW3Done(w3); }
public void Dispose() { if (this.wwwLoader != null) { this.wwwLoader.Dispose(); this.wwwLoader = null; } this.buffer = null; }
public void Complete() { if (this.wwwLoader != null) { this.wwwLoader.Dispose(); this.wwwLoader = null; } this.Progress = 1f; this.IsDone = true; }
public AssetBundleRelation(string bundleName, LoadProgress lp) { isloadFinished = false; this.bundleName = bundleName; this.lp = lp; assetLoader = new WWWLoader(bundleName, lp, LoadFinished); dependenceBundleList = new List <string>(); referBundleList = new List <string>(); }
private void AddLoader(WWW www) { WWWLoader item = new WWWLoader(www) { MaxRestartAttempts = 0, TimeoutSeconds = this.timeoutSeconds }; this.wwwLoaders.Add(item); }
protected override void Activate() { if (InitConfigurationActivator.LauncherPassed) { base.Complete(); } else { string url = InitConfiguration.Config.UpdateConfigUrl.Replace("{DataPath}", Application.dataPath).Replace("{BuildTarget}", BuildTargetName.GetName()); this.wwwLoader = new WWWLoader(new WWW(url)); } }
private void StartLoadFromHTTP() { this.url = AssetBundleNaming.GetAssetBundleUrl(this.assetBundleDiskCache.BaseUrl, this.AssetBundleInfo.Filename); if (this.loadFromHttpAttempts < RELOAD_FROM_HTTP_ATTEMPTS) { this.url = $"{this.url}?rnd={Random.value}"; } Console.WriteLine("Start download url: {0}", this.url); this.wwwLoader = new WWWLoader(new WWW(this.url)); this.wwwLoader.MaxRestartAttempts = 0; this.State = AssetBundleDiskCacheState.LOADING_FROM_HTTP; }
protected override void Activate() { if (LauncherPassed) { base.Complete(); } else { this.wwwLoader = new WWWLoader(new WWW(this.getInitUrl())); this.wwwLoader.MaxRestartAttempts = 0; } }
public IEnumerator downloadBundle() { string url = GameObject.Find("Url Field").GetComponent <UnityEngine.UI.InputField>().text; string bundlename = GameObject.Find("BundleName Field").GetComponent <UnityEngine.UI.InputField>().text; PlayerPrefs.SetString("ERROR", "Done Downloading Bundle" + bundlename); //clear error showStatusText("Downloading Bundle " + bundlename + "..."); yield return(WWWLoader.downloadFiles(url, bundlename)); LoadBundles(); isDownloading = false; showStatusText(PlayerPrefs.GetString("ERROR")); }
private Texture2D LoadTexture(WWWLoader loader) { if (loader.WWW.responseHeaders.ContainsKey("Content-Encoding") && loader.WWW.responseHeaders["Content-Encoding"].Equals("gzip")) { base.Log.WarnFormat("LoadTexture image is gzipped: {0}", loader.URL); Texture2D textured = new Texture2D(2, 2); return(!textured.LoadImage(DecompressGzip(loader.Bytes, loader.WWW.bytesDownloaded * 2), true) ? null : textured); } Texture2D tex = new Texture2D(2, 2, TextureFormat.ARGB32, false, false); loader.WWW.LoadImageIntoTexture(tex); return(tex); }
public void AccountLoginCorrect(string username, string pwd) { string salt = ""; string CorrectHashedPwd = ""; string answer = ""; password = pwd; UnityEngine.WWWForm form = new UnityEngine.WWWForm(); form.AddField("Command", "GetHashSalt"); form.AddField("acctName", username); WWWLoader.instance.myDelegate += OnGetHashAndSalt; WWWLoader.Load("http://unitytowerdefense.com/WebService.php", form); }
private void Update() { if (this.www != null) { this.progressBar.ProgressValue = this.www.Progress; if (this.www.IsDone) { this.progressBar.ProgressValue = 1f; this.CompleteDownloading(); this.www.Dispose(); this.www = null; } } }
static int Get(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); WWWLoader obj = (WWWLoader)ToLua.CheckObject <WWWLoader>(L, 1); string arg0 = ToLua.CheckString(L, 2); obj.Get(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void UrlLoadComplete(LoadCompleteEvent e, NewsItemWithUINode newsItem) { WWWLoader loader = (WWWLoader)newsItem.Entity.GetComponent <UrlLoaderComponent>().Loader; Texture tex = this.LoadTexture(loader); if (IsErrorImage(tex)) { base.Log.ErrorFormat("Image decode failed: {0} bytesDownloaded={1} bytesLength={2}", loader.URL, loader.WWW.bytesDownloaded, loader.WWW.bytes.Length); } else { base.Log.InfoFormat("PreviewImage loaded: {0}", loader.URL); this.textureCache[loader.URL] = tex; this.SetImage(newsItem, tex); } }
static int GetProgress(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); WWWLoader obj = (WWWLoader)ToLua.CheckObject <WWWLoader>(L, 1); string arg0 = ToLua.CheckString(L, 2); float o = obj.GetProgress(arg0); LuaDLL.lua_pushnumber(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void CreateAccount(string name, string password) { string Salt = CreateSalt(12); string Hash = CreatePasswordHash(password, Salt); string answer = ""; WWWForm form = new WWWForm(); form.AddField("Command", "CreateAccount"); form.AddField("acctName", name); form.AddField("acctHash", Hash); form.AddField("acctSalt", Salt); WWWLoader.instance.myDelegate += OnReceiveCreateAccountResponse; WWWLoader.Load("http://unitytowerdefense.com/WebService.php", form); }
static int get_loadingCount(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WWWLoader obj = (WWWLoader)o; int ret = obj.loadingCount; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index loadingCount on a nil value")); } }
static int get_onLoaded(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WWWLoader obj = (WWWLoader)o; System.Action <UnityEngine.WWW, string, string> ret = obj.onLoaded; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onLoaded on a nil value")); } }
static int set_onLoaded(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); WWWLoader obj = (WWWLoader)o; System.Action <UnityEngine.WWW, string, string> arg0 = (System.Action <UnityEngine.WWW, string, string>)ToLua.CheckDelegate <System.Action <UnityEngine.WWW, string, string> >(L, 2); obj.onLoaded = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onLoaded on a nil value")); } }
protected override void Activate() { if (Environment.GetCommandLineArgs().Contains <string>("-ignorestate")) { Debug.Log("Ignoring state.yml"); base.Complete(); } else if (InitConfigurationActivator.LauncherPassed) { base.Complete(); } else { string url = new CommandLineParser(Environment.GetCommandLineArgs()).GetValueOrDefault("-stateUrl", StartupConfiguration.Config.StateUrl) + "?rnd=" + new Random().NextDouble(); this.wwwLoader = new WWWLoader(new WWW(url)); this.wwwLoader.MaxRestartAttempts = 0; } }
private void RemoveExpiredLoaders() { for (int i = 0; i < this.wwwLoaders.Count; i++) { WWWLoader loader = this.wwwLoaders[i]; if (loader.IsDone) { if (!string.IsNullOrEmpty(loader.Error)) { object[] args = new object[] { loader.Error }; Debug.LogWarningFormat("UnityHTTPAppender: {0}", args); } loader.Dispose(); this.wwwLoaders.RemoveAt(i); i--; } } }
private void Update() { if ((this.wwwLoader != null) && this.wwwLoader.IsDone) { if (!string.IsNullOrEmpty(this.wwwLoader.Error)) { if (WWWLoader.GetResponseCode(this.wwwLoader.WWW) >= 400) { this.HandleError <TechnicalWorkEvent>(); } else { this.HandleError <NoServerConnectionEvent>($"Configuration loading was failed. URL: {this.wwwLoader.URL}, Error: {this.wwwLoader.Error}"); } } else if ((this.wwwLoader.Bytes == null) || (this.wwwLoader.Bytes.Length == 0)) { this.HandleError <GameDataLoadErrorEvent>("Empty server state data. URL: " + this.wwwLoader.URL); } else { string data = string.Empty; try { data = Encoding.UTF8.GetString(this.wwwLoader.Bytes); StateConfiguration configuration = yamlService.Load <StateConfiguration>(data); this.state = configuration.State; if (this.state != 0) { this.HandleError <TechnicalWorkEvent>(); } } catch (Exception exception) { this.HandleError <GameDataLoadErrorEvent>($"Invalid configuration data. URL: {this.wwwLoader.URL}, Error: {exception.Message}, Data: {data}"); return; } this.DisposeWWWLoader(); base.Complete(); } } }
protected override void Activate() { this.dbEntity = EngineService.Engine.CreateEntity("AssetBundleDatabase"); bool flag = true; string baseUrl = (InitConfiguration.Config.ResourcesUrl + "/" + BuildTargetName.GetName()).Replace("{DataPath}", Application.dataPath); string str2 = !"LATEST".Equals(InitConfiguration.Config.BundleDbVersion) ? ("-" + InitConfiguration.Config.BundleDbVersion) : string.Empty; string url = !flag?AssetBundleNaming.GetAssetBundleUrl(baseUrl, AssetBundleNaming.DB_PATH + str2) : (((Application.platform != RuntimePlatform.WindowsPlayer) ? "file://" : "file:///") + Application.dataPath + "/" + AssetBundleNaming.DB_FILENAME); WWWLoader loader = new WWWLoader(new WWW(url)) { MaxRestartAttempts = 0 }; this.dbLoader = loader; BaseUrlComponent component = new BaseUrlComponent { Url = baseUrl + "/" }; this.dbEntity.AddComponent(component); }
private void Update() { if ((this.wwwLoader != null) && this.wwwLoader.IsDone) { if (!string.IsNullOrEmpty(this.wwwLoader.Error)) { if (WWWLoader.GetResponseCode(this.wwwLoader.WWW) >= 400) { this.HandleError <TechnicalWorkEvent>(); } else { this.HandleError <NoServerConnectionEvent>($"Initial config loading was failed. URL: {this.wwwLoader.URL}, Error: {this.wwwLoader.Error}"); } } else if ((this.wwwLoader.Bytes == null) || (this.wwwLoader.Bytes.Length == 0)) { this.HandleError <GameDataLoadErrorEvent>("Initial config is empty. URL: " + this.wwwLoader.URL); } else { try { using (MemoryStream stream = new MemoryStream(this.wwwLoader.Bytes)) { StreamReader reader = new StreamReader(stream); InitConfiguration.Config = yamlService.Load <InitConfiguration>(reader); } } catch (Exception exception) { this.HandleError <GameDataLoadErrorEvent>($"Invalid initial config. URL: {this.wwwLoader.URL}, Error: {exception.Message}", exception); return; } this.DisposeWWWLoader(); base.Complete(); } } }
static int _CreateWWWLoader(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { WWWLoader obj = new WWWLoader(); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: WWWLoader.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public LoaderManager(){ GameObject _loader = new GameObject("_loader"); MonoBehaviour.DontDestroyOnLoad(_loader); loader = _loader.AddComponent<WWWLoader>(); }
async Task TestLoadOne(string url) { byte[] wwwBytes = await WWWLoader.AsyncLoad(url); Assert(wwwBytes.Length > 0); }