1、素材包获取
链接: https://pan.baidu.com/s/1KgCtQ_7wt2mlbGbIaMVvmw
提取码: xxh8
2、将素材全部拉进去
3、创建新的场景
并且将场景添加到build settings里面
4、脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class StartBtnLis : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
//监听鼠标按下
private void OnMouseDown()
{
//对象比例缩小
transform.localScale = transform.localScale * 0.8f;
}
//监听鼠标松开
private void OnMouseUp()
{
//对象比例放大
transform.localScale = transform.localScale / 0.8f;
//场景切换
SceneManager.LoadScene("game");
}
}
5添加脚本
将c#脚本长按拉动到对应指定的图层就会把脚本添加进去
6、添加2d盒装碰撞器
7、测试运行
点击按钮则能看到按钮动态缩小并跳转到对应的场景