public void DoAction() { if (GameOptions.Instance.UseAndroidNativeAudio) { ANAMusic.release(NativeAudioId); } switch (action) { case Action.Back: print("Loading LevelSelection scene."); StartCoroutine(View.ReturnToLevelSelectionCoroutine()); break; case Action.Retry: BackgroundCanvasHelper.PersistBackgroundCanvas(); SceneManager.LoadScene("CytusGame"); break; case Action.Result: BackgroundCanvasHelper.PersistBackgroundCanvas(); print("Loading GameResult scene."); SceneManager.LoadScene("GameResult"); break; } }
public void DoAction() { if (!CytoidApplication.CurrentLevel.isInternal && Application.platform == RuntimePlatform.Android) { ANAMusic.release(anaId); } switch (action) { case Action.Back: print("Loading LevelSelection scene."); StartCoroutine(GoBackToLevelSelectionCoroutine()); break; case Action.Retry: BackgroundCanvasHelper.PersistBackgroundCanvas(); SceneManager.LoadScene("Game"); break; case Action.Result: BackgroundCanvasHelper.PersistBackgroundCanvas(); print("Loading GameResult scene."); SceneManager.LoadScene("GameResult"); break; } }
public void DoAction() { BackgroundCanvasHelper.PersistBackgroundCanvas(); switch (action) { case Action.Retry: SceneManager.LoadScene("CytusGame"); break; case Action.Next: SceneManager.LoadScene("LevelSelection"); break; } }
public void DoAction() { switch (action) { case Action.Go: print("Loading Game scene."); PlayerPrefsExt.SetBool("early_late_indicator", earlyLateIndicatorToggle.isOn); PlayerPrefsExt.SetBool("larger_hitboxes", largerHitboxesToggle.isOn); BackgroundCanvasHelper.PersistBackgroundCanvas(); SceneManager.LoadScene("CytusGame"); break; } }
protected override void Awake() { base.Awake(); Application.targetFrameRate = 120; IsLoaded = false; IsPlaying = false; IsCompleted = false; IsFailed = false; UnpauseCountdown = -1; PauseTime = -1; PauseDuration = 0; PauseAt = -1; // Play data var isRanked = PlayerPrefsExt.GetBool("ranked") && OnlinePlayer.Authenticated; Play = new Play(isRanked); Play.Mods = new HashSet <Mod>(PlayerPrefsExt.GetStringArray("mods", new string[0]).ToList() .ConvertAll(mod => (Mod)Enum.Parse(typeof(Mod), mod))); CytoidApplication.CurrentPlay = Play; View = new GameView(this); // Enable/disable FPS counter var fpsCounter = GameObject.FindGameObjectWithTag("FpsCounter"); if (fpsCounter != null) { fpsCounter.SetActive(PlayerPrefsExt.GetBool("fps counter")); } boundaryTopAnimator = BoundaryTop.GetComponentInChildren <Animator>(); boundaryBottomAnimator = BoundaryBottom.GetComponentInChildren <Animator>(); if (!PlayerPrefsExt.GetBool("boundaries")) { BoundaryTop.GetComponentInChildren <SpriteRenderer>().enabled = false; BoundaryBottom.GetComponentInChildren <SpriteRenderer>().enabled = false; } BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); }
public void DoAction() { switch (action) { case Action.Go: print("Loading Game scene."); PlayerPrefs.SetFloat("user_offset", float.Parse(userOffsetInput.text)); PlayerPrefsExt.SetBool("show_scanner", showScannerToggle.isOn); PlayerPrefsExt.SetBool("inverse", isInversedToggle.isOn); PlayerPrefs.SetString("ring_color", ringColorInput.text); PlayerPrefs.SetString("ring_color_alt", ringColorAltInput.text); PlayerPrefs.SetString("fill_color", fillColorInput.text); PlayerPrefs.SetString("fill_color_alt", fillColorAltInput.text); BackgroundCanvasHelper.PersistBackgroundCanvas(); SceneManager.LoadScene("Game"); break; } }
protected override void Awake() { base.Awake(); CytoidApplication.SetAutoRotation(true); CytoidApplication.ResetResolution(); var ringColorDef = "#FFFFFF"; var ringColorAltDef = "#FFFFFF"; var fillColorDef = "#6699CC"; var fillColorAltDef = "#FF3C38"; SetDefaultPref("main offset", Application.platform == RuntimePlatform.Android ? 0f : 0.1f); SetDefaultPref("headset offset", -0.05f); SetDefaultPref("show_scanner", true); SetDefaultPref("inverse", false); SetDefaultPref("ring_color", ringColorDef); SetDefaultPref("ring_color_alt", ringColorAltDef); SetDefaultPref("fill_color", fillColorDef); SetDefaultPref("fill_color_alt", fillColorAltDef); SetDefaultPref("hit_sound", "None"); var list = HitSounds.ToList(); list.Insert(0, new HitSound { Name = "None" }); HitSounds = list.ToArray(); UpdateHitSound(HitSounds[1], save: false); var userHitSound = PlayerPrefs.GetString("hit_sound"); for (var index = 0; index < HitSounds.Length; index++) { if (HitSounds[index].Name == userHitSound) { UpdateHitSound(HitSounds[index]); HitSoundIndex = index; } } mainOffsetInput.text = PlayerPrefs.GetFloat("main offset").ToString(); headsetOffsetInput.text = PlayerPrefs.GetFloat("headset offset").ToString(); earlyLateIndicatorToggle.isOn = PlayerPrefsExt.GetBool("early_late_indicator"); largerHitboxesToggle.isOn = PlayerPrefsExt.GetBool("larger_hitboxes"); mainOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { mainOffsetInput.text = PlayerPrefs.GetFloat("main offset").ToString(); } else { PlayerPrefs.SetFloat("main offset", offset); } }); chartRelativeOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { chartRelativeOffsetInput.text = ZPlayerPrefs.GetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id)).ToString(); } else { ZPlayerPrefs.SetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id), offset); } }); headsetOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { headsetOffsetInput.text = PlayerPrefs.GetFloat("headset offset").ToString(); } else { PlayerPrefs.SetFloat("headset offset", offset); } }); usernameInput.text = PlayerPrefs.GetString(PreferenceKeys.LastUsername()); passwordInput.text = PlayerPrefs.GetString(PreferenceKeys.LastPassword()); if (!PlayerPrefs.HasKey("ranked")) { PlayerPrefsExt.SetBool("ranked", false); } rankStatusText.text = OnlinePlayer.Authenticated && PlayerPrefsExt.GetBool("ranked") ? "On" : "Off"; // Initialize background blackout.SetActive(false); var backgrounds = GameObject.FindGameObjectsWithTag("Background"); if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene) { var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene); // Destroy local background Destroy(localBackground); // Setup the persisted background BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } else // Setup the local background { BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } if (OnlinePlayer.Authenticated && OnlinePlayer.AvatarTexture != null) { LoadedAvatar = true; } if (Application.platform == RuntimePlatform.Android) { headsetOffsetInput.gameObject.SetActive(false); LayoutRebuilder.ForceRebuildLayoutImmediate(headsetOffsetInput.transform.parent.GetComponent <RectTransform>()); } EventKit.Subscribe <string>("meta reloaded", OnLevelMetaReloaded); }
private void Start() { CytoidApplication.ResetResolution(); IsUploading = false; SuccessfullyUploaded = false; BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); // HIGHLIGHT Resources.UnloadUnusedAssets(); // HIGHLIGHT if (OnlinePlayer.Authenticated) { StartCoroutine(AutoUpload()); } else { uploadButton.gameObject.SetActive(false); } var play = CytoidApplication.CurrentPlay; var score = play.Score; var tp = play.Tp; var maxCombo = play.MaxCombo; titleText.text = CytoidApplication.CurrentLevel.title; var intScore = Mathf.FloorToInt((float)score); scoreText.text = intScore.ToString("D6"); if (intScore == 1000000) { scoreText.color = Convert.HexToColor("#ffc107"); } else if (intScore > 999000) { scoreText.color = Convert.HexToColor("#007bff"); } var text = ""; if (Math.Abs(tp - 100) < 0.000001) { text += "Full accuracy"; } else { text += (Math.Floor(tp * 100) / 100).ToString("0.00") + "% accuracy"; } text += " / "; if (maxCombo == play.NoteCleared) { text += "Full combo"; } else { text += maxCombo + " max combo"; } tpComboText.text = text; var info = string.Format( "<b>Perfect</b> {0} <b>Great</b> {1} <b>Good</b> {2} <b>Bad</b> {3} <b>Miss</b> {4}", play.NoteRankings.Values.Count(grading => grading == NoteGrade.Perfect), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Great), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Good), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Bad), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Miss) ); if (PlayerPrefsExt.GetBool("early_late_indicator")) { info += string.Format("\n<alpha=#38>( <b>Early</b> {0} <b>Late</b> {1} <b>Average Timing Error</b> {2}{3:0.000}s <b>Standard Timing Error</b> {4:0.000}s )", play.Early, play.Late, play.AvgTimeOff > 0 ? "+" : "", play.AvgTimeOff, play.StandardTimeOff); } infoText.text = info; DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentLevel, CytoidApplication.CurrentLevel.charts.Find(it => it.type == CytoidApplication.CurrentChartType)); var ranked = CytoidApplication.CurrentRankedPlayData != null; // Save stats var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked)); var oldAccuracy = ZPlayerPrefs.GetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked)); var newBest = false; if (score > oldScore) { newBest = true; ZPlayerPrefs.SetFloat( PreferenceKeys.BestScore(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked), (float)score); var clearType = string.Empty; if (play.Mods.Contains(Mod.AP)) { clearType = "AP"; } if (play.Mods.Contains(Mod.FC)) { clearType = "FC"; } if (play.Mods.Contains(Mod.Hard)) { clearType = "Hard"; } if (play.Mods.Contains(Mod.ExHard)) { clearType = "ExHard"; } ZPlayerPrefs.SetString( PreferenceKeys.BestClearType(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked), clearType ); } if (tp > oldAccuracy) { newBest = true; ZPlayerPrefs.SetFloat( PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked), (float)tp); } if (newBest) { EventKit.Broadcast("new best"); } var playCount = ZPlayerPrefs.GetInt( PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType), defaultValue: 0); ZPlayerPrefs.SetInt( PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType), playCount + 1); }
protected override void Awake() { base.Awake(); CytoidApplication.SetAutoRotation(true); var userOffsetDef = Application.platform == RuntimePlatform.Android ? 0.12f : 0.2f; var ringColorDef = "#FFFFFF"; var ringColorAltDef = "#FFFFFF"; var fillColorDef = "#6699CC"; var fillColorAltDef = "#FF3C38"; SetDefaultPref("user_offset", userOffsetDef); SetDefaultPref("show_scanner", true); SetDefaultPref("inverse", false); SetDefaultPref("ring_color", ringColorDef); SetDefaultPref("ring_color_alt", ringColorAltDef); SetDefaultPref("fill_color", fillColorDef); SetDefaultPref("fill_color_alt", fillColorAltDef); SetDefaultPref("hit_sound", "None"); var list = HitSounds.ToList(); list.Insert(0, new HitSound { Name = "None", Clip = null }); HitSounds = list.ToArray(); UpdateHitSound(HitSounds[1], save: false); var userHitSound = PlayerPrefs.GetString("hit_sound"); for (var index = 0; index < HitSounds.Length; index++) { if (HitSounds[index].Name == userHitSound) { UpdateHitSound(HitSounds[index]); HitSoundIndex = index; } } userOffsetInput.text = PlayerPrefs.GetFloat("user_offset").ToString(); showScannerToggle.isOn = PlayerPrefsExt.GetBool("show_scanner"); earlyLateIndicatorToggle.isOn = PlayerPrefsExt.GetBool("early_late_indicator"); largerHitboxesToggle.isOn = PlayerPrefsExt.GetBool("larger_hitboxes"); isInversedToggle.isOn = PlayerPrefsExt.GetBool("inverse"); ringColorInput.text = PlayerPrefs.GetString("ring_color"); ringColorAltInput.text = PlayerPrefs.GetString("ring_color_alt"); fillColorInput.text = PlayerPrefs.GetString("fill_color"); fillColorAltInput.text = PlayerPrefs.GetString("fill_color_alt"); userOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { userOffsetInput.text = userOffsetDef.ToString(); } }); overrideOptionsToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), selected); }); localIsInversedToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), selected); }); localUserOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { localUserOffsetInput.text = userOffsetInput.text; } else { ZPlayerPrefs.SetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel), offset); } }); ringColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorInput.text = ringColorDef; } }); ringColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorAltInput.text = ringColorAltDef; } }); fillColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorInput.text = fillColorDef; } }); fillColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorAltInput.text = fillColorAltDef; } }); usernameInput.text = PlayerPrefs.GetString(PreferenceKeys.LastUsername()); passwordInput.text = PlayerPrefs.GetString(PreferenceKeys.LastPassword()); if (!PlayerPrefs.HasKey(PreferenceKeys.RankedMode())) { PlayerPrefsExt.SetBool(PreferenceKeys.RankedMode(), false); } rankStatusText.text = "Off"; // Initialize background blackout.SetActive(false); var backgrounds = GameObject.FindGameObjectsWithTag("Background"); if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene) { var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene); // Destroy local background Destroy(localBackground); // Setup the persisted background BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } else // Setup the local background { BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } }
private void Start() { IsUploading = false; BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); // HIGHLIGHT Resources.UnloadUnusedAssets(); // HIGHLIGHT StartCoroutine(AutoUpload()); var score = CytoidApplication.LastPlayResult.Score; var tp = CytoidApplication.LastPlayResult.Tp; var maxCombo = CytoidApplication.LastPlayResult.MaxCombo; titleText.text = CytoidApplication.CurrentLevel.title; var intScore = Mathf.CeilToInt((float)score); scoreText.text = intScore.ToString("D6"); if (intScore == 1000000) { scoreText.color = Convert.HexToColor("#FDE74C"); } var result = CytoidApplication.LastPlayResult; var text = ""; if (Math.Abs(tp - 100) < 0.000001) { text += "Full accuracy"; } else { text += tp.ToString("0.##") + "% accuracy"; } text += " / "; if (maxCombo == result.TotalCount) { text += "Full combo"; } else { text += maxCombo + " max combo"; } tpComboText.text = text; var info = string.Format("<b>Perfect </b> {0} <b>Great </b> {1} <b>Good </b> {2} <b>Bad </b> {3} <b>Miss </b> {4}", result.PerfectCount, result.GreatCount, result.GoodCount, result.BadCount, result.MissCount); infoText.text = info; DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType, CytoidApplication.CurrentLevel.GetDifficulty(CytoidApplication.CurrentChartType)); var ranked = result.Ranked; // Save stats var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType, ranked)); var oldTp = ZPlayerPrefs.GetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType, ranked)); if (score > oldScore) { ZPlayerPrefs.SetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType, ranked), (float)score); } if (tp > oldTp) { ZPlayerPrefs.SetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType, ranked), (float)tp); } var playCount = ZPlayerPrefs.GetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), defaultValue: 0); ZPlayerPrefs.SetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), playCount + 1); if (ranked) { var rankedPlayData = CytoidApplication.CurrentRankedPlayData; rankedPlayData.score = (long)score; rankedPlayData.accuracy = (int)(tp * 1000000); rankedPlayData.max_combo = maxCombo; rankedPlayData.perfect = result.PerfectCount; rankedPlayData.great = result.GreatCount; rankedPlayData.good = result.GoodCount; rankedPlayData.bad = result.BadCount; rankedPlayData.miss = result.MissCount; rankedPlayData.checksum = Checksum.From(rankedPlayData); } else { levelInfoIndicator.transform.SetLocalX(rankedIndicator.transform.localPosition.x); rankedIndicator.SetActive(false); } }
protected override void Awake() { base.Awake(); BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); }
private void Start() { BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); // HIGHLIGHT Resources.UnloadUnusedAssets(); // HIGHLIGHT var score = CytoidApplication.LastPlayResult.Score; var tp = CytoidApplication.LastPlayResult.Tp; titleText.text = CytoidApplication.CurrentLevel.title; scoreText.text = Mathf.CeilToInt(score).ToString("D6"); tpText.text = tp.ToString("0.##") + "% Accuracy"; comboText.text = CytoidApplication.LastPlayResult.MaxCombo + " Max. Combo"; var result = CytoidApplication.LastPlayResult; var info = ""; info += result.PerfectCount + " Perfect "; info += result.ExcellentCount + " Excellent "; info += result.GoodCount + " Good "; info += result.BadCount + " Bad "; info += result.MissCount + " Miss"; infoText.text = info; DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType, CytoidApplication.CurrentLevel.GetDifficulty(CytoidApplication.CurrentChartType)); // Save stats var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType)); var oldTp = ZPlayerPrefs.GetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType)); if (score > oldScore) { ZPlayerPrefs.SetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), score); } if (tp > oldTp) { ZPlayerPrefs.SetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), tp); } var playCount = ZPlayerPrefs.GetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), defaultValue: 0); ZPlayerPrefs.SetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), playCount + 1); if (!CytoidApplication.UseDoozyUI) { nextButton.onClick.AddListener(() => { action = Action.Next; DoAction(); }); retryButton.onClick.AddListener(() => { action = Action.Retry; DoAction(); }); } }
protected override void Awake() { base.Awake(); CytoidApplication.SetAutoRotation(true); var userOffsetDef = Application.platform == RuntimePlatform.Android ? 0.12f : 0.2f; var ringColorDef = "#FFFFFF"; var ringColorAltDef = "#FFFFFF"; var fillColorDef = "#6699CC"; var fillColorAltDef = "#FF3C38"; SetDefaultPref("user_offset", userOffsetDef); SetDefaultPref("show_scanner", true); SetDefaultPref("inverse", false); SetDefaultPref("ring_color", ringColorDef); SetDefaultPref("ring_color_alt", ringColorAltDef); SetDefaultPref("fill_color", fillColorDef); SetDefaultPref("fill_color_alt", fillColorAltDef); userOffsetInput.text = PlayerPrefs.GetFloat("user_offset").ToString(); showScannerToggle.isOn = PlayerPrefsExt.GetBool("show_scanner"); isInversedToggle.isOn = PlayerPrefsExt.GetBool("inverse"); ringColorInput.text = PlayerPrefs.GetString("ring_color"); ringColorAltInput.text = PlayerPrefs.GetString("ring_color_alt"); fillColorInput.text = PlayerPrefs.GetString("fill_color"); fillColorAltInput.text = PlayerPrefs.GetString("fill_color_alt"); userOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { userOffsetInput.text = userOffsetDef.ToString(); } }); overrideOptionsToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), selected); }); localIsInversedToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), selected); }); localUserOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { localUserOffsetInput.text = userOffsetInput.text; } else { ZPlayerPrefs.SetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel), offset); } }); ringColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorInput.text = ringColorDef; } }); ringColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorAltInput.text = ringColorAltDef; } }); fillColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorInput.text = fillColorDef; } }); fillColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorAltInput.text = fillColorAltDef; } }); // Initialize background blackout.SetActive(false); var backgrounds = GameObject.FindGameObjectsWithTag("Background"); if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene) { var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene); // Destroy local background Destroy(localBackground); // Setup the persisted background BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } else // Setup the local background { BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } }