修了很多bug和增加功能,优化不少问题
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Bansonic;
|
||||
using UnityEngine.SceneManagement;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
@@ -33,40 +34,72 @@ public class userSettings : MonoBehaviour
|
||||
|
||||
private const string RuntimeResourcesPath = "song_songIndex";
|
||||
private const string EditorAssetsPath = "Assets/Resources/song_songIndex";
|
||||
[SerializeField] private float clearupConfirmSeconds = 2f;
|
||||
private bool clearupPending;
|
||||
[SerializeField] private float clearupConfirmSeconds = 5f;
|
||||
private int clearupClickCount = 0;
|
||||
private float clearupExpireTime;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (clearup_saveData_button != null)
|
||||
clearup_saveData_button.onClick.AddListener(OnClearupSaveDataClicked);
|
||||
|
||||
if (export_saveData_button != null) export_saveData_button.onClick.AddListener(ResetClearupCounter);
|
||||
if (import_saveData_button != null) import_saveData_button.onClick.AddListener(ResetClearupCounter);
|
||||
if (view_detailedHighlight_button != null) view_detailedHighlight_button.onClick.AddListener(ResetClearupCounter);
|
||||
if (language_dropdown != null) language_dropdown.onValueChanged.AddListener(_ => ResetClearupCounter());
|
||||
|
||||
ResetClearupCounter();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (clearup_saveData_button != null)
|
||||
clearup_saveData_button.onClick.RemoveListener(OnClearupSaveDataClicked);
|
||||
|
||||
if (export_saveData_button != null) export_saveData_button.onClick.RemoveListener(ResetClearupCounter);
|
||||
if (import_saveData_button != null) import_saveData_button.onClick.RemoveListener(ResetClearupCounter);
|
||||
if (view_detailedHighlight_button != null) view_detailedHighlight_button.onClick.RemoveListener(ResetClearupCounter);
|
||||
if (language_dropdown != null) language_dropdown.onValueChanged.RemoveListener(_ => ResetClearupCounter());
|
||||
|
||||
ResetClearupCounter();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (clearupPending && Time.unscaledTime > clearupExpireTime)
|
||||
clearupPending = false;
|
||||
if (clearupClickCount > 0 && Time.unscaledTime > clearupExpireTime)
|
||||
{
|
||||
ResetClearupCounter();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetClearupCounter()
|
||||
{
|
||||
clearupClickCount = 0;
|
||||
}
|
||||
|
||||
private void OnClearupSaveDataClicked()
|
||||
{
|
||||
if (clearupPending && Time.unscaledTime <= clearupExpireTime)
|
||||
if (clearupClickCount > 0 && Time.unscaledTime > clearupExpireTime)
|
||||
{
|
||||
clearupPending = false;
|
||||
StartCoroutine(ClearSongDataRoutine());
|
||||
return;
|
||||
ResetClearupCounter();
|
||||
}
|
||||
|
||||
clearupPending = true;
|
||||
clearupClickCount++;
|
||||
clearupExpireTime = Time.unscaledTime + clearupConfirmSeconds;
|
||||
gNotice.alarm.display("再次按下清空存档");
|
||||
|
||||
if (clearupClickCount == 1)
|
||||
{
|
||||
gNotice.warning.display("此操作将重置存档");
|
||||
}
|
||||
else if (clearupClickCount == 2)
|
||||
{
|
||||
gNotice.error.display("再次点击以确认此危险操作");
|
||||
}
|
||||
else if (clearupClickCount >= 3)
|
||||
{
|
||||
ResetClearupCounter();
|
||||
StartCoroutine(ClearSongDataRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ClearSongDataRoutine()
|
||||
@@ -112,5 +145,12 @@ public class userSettings : MonoBehaviour
|
||||
if ((index % 16) == 0)
|
||||
yield return null;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
AssetDatabase.SaveAssets();
|
||||
#endif
|
||||
|
||||
// 完成后返回主界面
|
||||
SceneManager.LoadScene("Main_main");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user