修了很多bug和增加功能,优化不少问题

This commit is contained in:
2026-02-28 06:59:22 +08:00
parent 508a40bba0
commit e11cc1da7a
345 changed files with 173803 additions and 69332 deletions
+54 -1
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -44,6 +44,12 @@ public class controllerSettings : MonoBehaviour
private const float ContinuousRepeatRate = 0.05f;
private const float StepAmount = 0.01f;
[Header("call dt prefab")]
public GameObject delayTapper_prefab;
public GameObject dt_to_put;
public Button launch_delayTapper;
public Text currentDelayText;
void Start()
{
// initialize button labels from KeyBindingManager
@@ -106,6 +112,53 @@ public class controllerSettings : MonoBehaviour
noteSpeed_ResetButton.onClick.RemoveAllListeners();
noteSpeed_ResetButton.onClick.AddListener(() => ResetNoteSpeed());
}
// Initialize delay tapper button and display
if (launch_delayTapper != null)
{
launch_delayTapper.onClick.RemoveAllListeners();
launch_delayTapper.onClick.AddListener(OnLaunchDelayTapperClicked);
}
RefreshDelayText();
}
public void RefreshDelayText()
{
if (currentDelayText != null)
{
const string DELAY_PREFS_KEY = "UserGlobalDelaySeconds";
if (PlayerPrefs.HasKey(DELAY_PREFS_KEY))
{
float savedDelaySeconds = PlayerPrefs.GetFloat(DELAY_PREFS_KEY, 0f);
int ms = Mathf.RoundToInt(savedDelaySeconds * 1000f);
currentDelayText.text = $"当前偏移:{(ms >= 0 ? "+" : "")}{ms}ms";
}
else
{
currentDelayText.text = "未设定偏移数值";
}
}
}
public void OnLaunchDelayTapperClicked()
{
if (delayTapper_prefab != null && dt_to_put != null)
{
GameObject instantiated = Instantiate(delayTapper_prefab, dt_to_put.transform);
Debug.Log($"[controllerSettings] Instantiated delay tapper prefab under {dt_to_put.name}");
// 获取 dtp 脚本并传递当前 settings 引用,以便保存时刷新 UI
delayTapperPrefab dtp = instantiated.GetComponent<delayTapperPrefab>();
if (dtp != null)
{
dtp.mainSettings = this;
}
}
else
{
Debug.LogWarning("[controllerSettings] Prefab or target container is missing!");
}
}
void OnDestroy()
+50 -10
View File
@@ -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");
}
}