using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class KaiShiAnNiu : MonoBehaviour { public Button kaiShiAnNiu; private void KaiShi() { // 获取按钮组件并添加 OnClick 事件 kaiShiAnNiu = GameObject.Find("KaiShiYouXiAnNiu").GetComponent<Button>(); kaiShiAnNiu.onClick.AddListener(KaiShiYouXi); Debug.Log("点击开始按钮"); } private void KaiShiYouXi() { // 跳转到角色选择场景 SceneManager.LoadScene("RoleSelectScene"); } private void Start() { KaiShi(); } }
时间: 2024-04-16 07:26:00 浏览: 97
Unity UnityEngine.UI 源码工程
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class KaiShiAnNiu : MonoBehaviour
{
public Button kaiShiAnNiu;
private void KaiShi()
{
// 获取按钮组件并添加 OnClick 事件
kaiShiAnNiu = GameObject.Find("KaiShiYouXiAnNiu").GetComponent<Button>();
kaiShiAnNiu.onClick.AddListener(KaiShiYouXi);
Debug.Log("点击开始按钮");
}
private void KaiShiYouXi()
{
// 跳转到角色选择场景
SceneManager.LoadScene("RoleSelectScene");
}
private void Start()
{
KaiShi();
}
}
阅读全文