From 535112b5296ab5445492992352a530471bb4b170 Mon Sep 17 00:00:00 2001 From: "a.gorbunov" <0alexgorbynov0@gmail.com> Date: Wed, 29 Nov 2023 13:10:35 +0300 Subject: [PATCH] Create hotkey to reset daily or global leader board. --- Assets/Scripts/LeaderboardController.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/LeaderboardController.cs b/Assets/Scripts/LeaderboardController.cs index 5bfd2863..44a6cda9 100644 --- a/Assets/Scripts/LeaderboardController.cs +++ b/Assets/Scripts/LeaderboardController.cs @@ -19,6 +19,10 @@ public class LeaderboardController : MonoBehaviour public UnityEvent> OnDailyInit; public UnityEvent> OnGlobalInit; + private bool _resetDaily = false; + private bool _resetGlobal = false; + + private void Awake() { //transform.parent = null; @@ -34,12 +38,24 @@ public class LeaderboardController : MonoBehaviour } } - private void Start() + private IEnumerator Start() { - //yield return new WaitForSeconds(1); + yield return new WaitForSeconds(10); + if(_resetDaily) + PlayerPrefs.SetString(DAILY_ID, string.Empty); + if(_resetGlobal) + PlayerPrefs.SetString(GLOBAL_ID, string.Empty); InitLeaderboards(); } + private void Update() + { + if(Input.GetKeydown(KeyCode.J)) + _resetDaily = true; + if(Input.GetKeydown(KeyCode.K)) + _resetGlobal = true; + } + public void InitLeaderboards() { InitDailyLeaderboard();