利用scenes 场景跳转
File ---> building settings
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement; //场景的命名空间
using System.IO;
using UnityEngine.UI;
public class JumpPage : MonoBehaviour {
private Button button;
public string NextSceneName;
void Awake()
{
//获取Button
Button button = gameObject.GetComponent<Button>();
//添加监听器用于监听按键事件,并回调函数
button.onClick.AddListener(btClick); //unity面板的增添
}
void Start () {
}
void Update()
{
}
void btClick()
{
//print("Button Click");
Debug.Log("Button Click");
SceneManager.LoadScene(NextSceneName); //跳转到指定的Level,也就是第一步中的右侧标号
}
}
按钮的跳转
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Sprites;
public class bgJump : MonoBehaviour {
public Transform startBG;
public Transform bgGameInterface;
void Start () {
}
// Update is called once per frame
private void Update()
{
}
public void bgGameInterfaceClick()
{
startBG.gameObject.SetActive(false);
bgGameInterface.gameObject.SetActive(true);
}
public void bgGameInterfaceQuitClick()
{
startBG.gameObject.SetActive(true);
bgGameInterface.gameObject.SetActive(false);
}
网友评论