feat: 自动更新按钮上的文字

This commit is contained in:
2026-04-16 11:52:38 +08:00
parent b13b8f6ff6
commit a085e182c4
2 changed files with 51 additions and 16 deletions
+4 -10
View File
@@ -7,25 +7,19 @@ namespace OCES
{
public class ButtonInvoker : MonoBehaviour
{
public TileMaterial targetGameState;
public GameState targetGameState;
public bool enableLowpass;
public Text buttonText;
Button m_button;
void Awake()
{
this.m_button = GetComponent<Button>();
this.m_button.onClick.AddListener(ButtonPressed);
this.buttonText.text = this.buttonText.text.Replace("PlaceHolder", this.targetGameState.ToString());
}
void OnDestroy()
{
this.m_button.onClick.RemoveListener(ButtonPressed);
}
private void ButtonPressed()
public void OnButtonPressed()
{
AudioSystem.Instance.SetState(this.targetGameState);