_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/RacingPanel/BetBtn.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2024-11-27 22:24:11 +08:00
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class BetBtn : MonoBehaviour
{
public static BetBtn instance;
public GameObject BetList;
public Button NumBtn;
public Text BetText;
public float BetValue;//Ͷע<CDB6><D7A2>ֵ
public float AllBetValue;//Ͷע<CDB6><D7A2>ֵ
public Button BetButton;//Ͷע<CDB6>İ<EFBFBD>ť
// Start is called before the first frame update
void Start()
{
instance = this;
BetList.SetActive(false);
NumBtn.onClick.AddListener(OnClickNumBtn);
BetValue = 50;//Ĭ<><C4AC>50
SetBet();
}
// Update is called once per frame
void Update()
{
}
void OnClickNumBtn()
{
BetList.SetActive(true);
}
void SetBet()
{
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD>Button<6F><6E><EFBFBD><EFBFBD>
Button[] buttons = BetList.GetComponentsInChildren<Button>();
// <20><><EFBFBD><EFBFBD>ÿһ<C3BF><D2BB>Button<6F><6E><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>¼<EFBFBD>
foreach (Button button in buttons)
{
button.onClick.AddListener(() => {
BetText.text = button.transform.GetComponentInChildren<Text>().text;
BetValue = float.Parse(BetText.text);
BetList.SetActive(false);
});
}
}
}