unity 3D 为image控件添加点击事件的两种方法:
第一种:适用于只有image控件,里面包含元素填充整个物体:
1.选择image物体,点击add component ,添加event trigger;
2.点加 add new event type,然后点击加号,增加pointer click方法;
3.书写point 对应的脚本,绑定到pointer click方法上。
第二种:image中包含多个物体,且物体之间存在间隔,为避免点击到物体之间的空格出,事件无法响应,需用另一种形势:
1.选择image物体,点击add component ,添加button属性;
2.然后点击加号,增加on click方法;
3.书写point 对应的脚本,绑定到point click方法上。
unity 3D 为image控件添加点击事件
最新推荐文章于 2024-08-13 19:04:50 发布