拼ui 一些业务逻辑x实现
This commit is contained in:
@@ -34,14 +34,42 @@ public class UI_Player : MonoBehaviour
|
||||
public Text firstFCsong;
|
||||
public Text totalPlayTime;
|
||||
|
||||
[Header("buttons")]
|
||||
public Button quitButton;
|
||||
|
||||
private readonly List<GameObject> spawnedInfoEntries = new List<GameObject>();
|
||||
private Color defaultInfoColor = Color.black;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
BindQuitButton();
|
||||
StartCoroutine(InitializeAsync());
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (quitButton != null)
|
||||
{
|
||||
quitButton.onClick.RemoveListener(ClosePanel);
|
||||
}
|
||||
}
|
||||
|
||||
private void BindQuitButton()
|
||||
{
|
||||
if (quitButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
quitButton.onClick.RemoveListener(ClosePanel);
|
||||
quitButton.onClick.AddListener(ClosePanel);
|
||||
}
|
||||
|
||||
private void ClosePanel()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private IEnumerator InitializeAsync()
|
||||
{
|
||||
StoreOwnershipLedger.EnsureInstance().InitializeIfNeeded();
|
||||
@@ -60,11 +88,9 @@ public class UI_Player : MonoBehaviour
|
||||
private string EnsureFirstLaunchDate()
|
||||
{
|
||||
string playerPrefsDate = PlayerPrefs.GetString(FirstLaunchDatePrefKey, string.Empty);
|
||||
string soDate = pSO != null ? pSO.firstLaunchDate : string.Empty;
|
||||
|
||||
string finalDate = !string.IsNullOrWhiteSpace(playerPrefsDate)
|
||||
? playerPrefsDate
|
||||
: (!string.IsNullOrWhiteSpace(soDate) ? soDate : DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
: DateTime.Now.ToString("yyyy-MM-dd");
|
||||
|
||||
if (playerPrefsDate != finalDate)
|
||||
{
|
||||
@@ -76,7 +102,10 @@ public class UI_Player : MonoBehaviour
|
||||
{
|
||||
pSO.firstLaunchDate = finalDate;
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(pSO);
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
UnityEditor.EditorUtility.SetDirty(pSO);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user