public static IEnumerator LoadLoadingScreen(string data) { LoadingScreenData screenData = new LoadingScreenData(data); Dbgl($"data: {data}\n\tpath: {screenData.screen}\n\ttip: {screenData.tip}"); if (data == null || screenData.screen == null || screenData.screen.Length == 0) { Dbgl("malformed data"); loadedSprite = true; yield break; } loadedSprite = false; loadingTip = screenData.tip; using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(screenData.screen)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Debug.Log(uwr.error); loadedSprite = true; } else { Dbgl($"Loaded texture from {screenData.screen}!"); var tex = DownloadHandlerTexture.GetContent(uwr); loadingSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1); if (false && Hud.instance != null) { Dbgl($"setting sprite to menu background screen"); Hud.instance.m_loadingProgress.SetActive(true); Hud.instance.m_loadingScreen.alpha = 1; //Hud.instance.m_loadingImage.sprite = differentSpawnScreen.Value && loadingSprite2 != null ? loadingSprite2 : loadingSprite; Hud.instance.m_loadingImage.sprite = loadingSprite; Hud.instance.m_loadingImage.color = spawnColorMask.Value; if (loadingTip.Any()) { Hud.instance.m_loadingTip.text = loadingTip; } Hud.instance.m_loadingTip.color = tipTextColor.Value; if (removeVignette.Value) { Hud.instance.m_loadingProgress.transform.Find("TopFade").gameObject.SetActive(false); Hud.instance.m_loadingProgress.transform.Find("BottomFade").gameObject.SetActive(false); Hud.instance.m_loadingProgress.transform.Find("text_darken").gameObject.SetActive(false); } Traverse.Create(Hud.instance).Field("m_haveSetupLoadScreen").SetValue(true); } loadedSprite = true; } } }
public static IEnumerator LoadLoadingScreen(string data) { LoadingScreenData screenData = new LoadingScreenData(data); Dbgl($"data: {data}\n\tpath: {screenData.screen}\n\ttip: {screenData.tip}"); if (data == null || screenData.screen == null || screenData.screen.Length == 0) { Dbgl("malformed data"); loadedSprite = true; yield break; } loadedSprite = false; loadingTip = screenData.tip; using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(screenData.screen)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Dbgl(uwr.error); loadedSprite = true; } else { Dbgl($"Loaded texture from {screenData.screen}!"); var tex = DownloadHandlerTexture.GetContent(uwr); loadingSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1); if (Hud.instance != null) { Dbgl($"setting sprite to menu background screen"); Image image = Instantiate(Hud.instance.transform.Find("LoadingBlack").Find("Bkg").GetComponent <Image>(), Hud.instance.transform.Find("LoadingBlack").transform); if (image == null) { Dbgl($"missed bkg"); yield break; } Dbgl($"setting sprite to loading screen"); image.sprite = loadingSprite; image.color = spawnColorMask.Value; image.type = Image.Type.Simple; image.preserveAspect = true; if (loadingTip.Length > 0) { Instantiate(Hud.instance.m_loadingTip.transform.parent.Find("panel_separator"), Hud.instance.transform.Find("LoadingBlack").transform); Text text = Instantiate(Hud.instance.m_loadingTip.gameObject, Hud.instance.transform.Find("LoadingBlack").transform).GetComponent <Text>(); if (text != null) { text.text = loadingTip; text.color = tipTextColor.Value; } } } loadedSprite = true; } } }