hold音符补丁 备份
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class gameSettings : MonoBehaviour
|
||||
{
|
||||
public Toggle multiNoteNoticeToggle;
|
||||
public Text multiNoteNoticeText; // Using Legacy Text object
|
||||
|
||||
private const string PrefKey_EnableSyncNotePrefab = "EnableSyncNotePrefab";
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (multiNoteNoticeToggle != null)
|
||||
{
|
||||
// Initialize toggle state from PlayerPrefs, default to 1 (true)
|
||||
bool isEnabled = PlayerPrefs.GetInt(PrefKey_EnableSyncNotePrefab, 1) == 1;
|
||||
multiNoteNoticeToggle.isOn = isEnabled;
|
||||
|
||||
// Initialize text based on current toggle value
|
||||
UpdateText(isEnabled);
|
||||
|
||||
// Add listener to save value and update text when changed
|
||||
multiNoteNoticeToggle.onValueChanged.AddListener((isOn) =>
|
||||
{
|
||||
PlayerPrefs.SetInt(PrefKey_EnableSyncNotePrefab, isOn ? 1 : 0);
|
||||
PlayerPrefs.Save();
|
||||
UpdateText(isOn);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateText(bool isOn)
|
||||
{
|
||||
if (multiNoteNoticeText != null)
|
||||
{
|
||||
multiNoteNoticeText.text = isOn ? "已启用多押指示器" : "已禁用多押指示器";
|
||||
}
|
||||
|
||||
// Also update the Toggle's own label text if it exists (usually a child object)
|
||||
Text toggleLabel = multiNoteNoticeToggle.GetComponentInChildren<Text>();
|
||||
if (toggleLabel != null)
|
||||
{
|
||||
toggleLabel.text = isOn ? "启用" : "禁用";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 689de294fb913594ab2f3185279f7093
|
||||
Reference in New Issue
Block a user