UGUI 学习笔记 6 Button

Button
1. 属性详解

Interactable : Will this component will accept input? 是否可用
Transition : Properties that determine the way the control responds visually to user actions. 状态变化

Navigation : Properties that determine the swquesce of controls. 热键关联
On Click : A UnityEvent that is invoked when a user clicks the button and releases is. 点击事件
2. Transiton 详解
Transition有三个类型Color Tint 色彩,Sprite Swap 图片,Animation 动画,只能有一种类型的效果。
Color Tint
这里写图片描述
Target Graphic:目标图片,默认Button中的Image
Normal Color:正常颜色。
Highlighted Color :选中时的颜色
Pressed Color :按下时的颜色
Disabled Color :失效时的颜色。
Color Multiplier :颜色增强
Fade Duration :渐变时间

Sprite Swap
这里写图片描述
和Color Tint 一样的原理
Animation
这里写图片描述
Normal Trigger :正常状态动画名字
Highlightes Trigger :选中状态动画的名字
Pressed Trigger :按下状态的动画名字
Disabled Trigger :失效状态的动画名字
设置好名字后,点 Auto Generate Animation生成动画文件,在动画文件里调出想要的动画就可以了。
这里写图片描述

这里写图片描述
3. Navigation 详解
选中按钮后,按键盘上的四个方向键,会让下一个按钮被选中。有4个类型,Automatic自动,Horizontal水平,,Vertical垂直。Explicit固定。
点击 Visualize按钮可以查看按钮间的关系
这里写图片描述
黄色线条就是按钮间的关系。
4. 添加点击事件
这里写图片描述
在代码中动态添加事件。
btn.onClick.AddListener(buttonClickAuto);
4.6以后允许匿名委托
btn.onClick.AddListener(delegate ()
{
buttonClickAuto(btn.gameObject);
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值