我想实现通过单击按钮,就能切换到另一个场景的功能?
希望提供有效代码,以及必须的步骤。
另外,我想(我心里想)更改button颜色为透明应该也能触发吧?
1.右键UI->Button;
2.找到pressed color,改为透明;
3.新建一个脚本,写一个public方法;
void HomeButtonClick()
{
SceneManager.LoadScene("Home");
}
4.回到按钮找到添加监听的地方;
5.将你挂刚才新建脚本的物体拖进来,然后找到这个public homebuttonclick方法;
6.完成。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scene : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void HomeButtonClick()
{
SceneManager.LoadScene("game");
}
}
我的代码,还是Can't add script 我也不知道什么是unity脚本QAQ