1.软件环境:unity2019.4.12f1,Visual Studio2019;
2.unity工程设置:
右键在UI中添加Button组件
接下来添加C#脚本
将此脚本挂在Button的父物体上,后面会用到transfrom来查找到Button;如果用GameObject查找则没有这个问题具体请见:
GameObject.Find与transform.Find的区别
3.代码书写
完成功能:实现点击按钮改变Cube颜色
using System.Collections;
using System.Collections.Generic;