Unity3D工作笔记 联系客服

发布时间 : 星期五 文章Unity3D工作笔记更新完毕开始阅读

设置Checkbox

1、 取消默认选择:

选择Checkbox,把UICheckbox组件中的Starts Checked(默认选中)取消掉。 2、 Checkbox控制拖动图标:

为Checkbox添加一个CheckboxComponent组件(Component->NGUI->Interaction->

CheckboxComponent),把UIGrid赋值给该组件的Target;

3、 Checkbox控制被选择图框显示与关闭:

为Checkbox再添加一个CheckboxCompo nent,把SlicedSprite(Row Outline)赋值给它的Target

Checkbox定位设置:

选中UIGrid?为其添加一个CenterOnChild组件(Component-> NGUI -> Interaction ->

CenterOnChild)?并关闭它,(这里有一个细节,checkbox controller component在控制target对象的组件开关时,它只对第一个组件进行控制,所以,我们要把UICenterOnChild放在UIGrid组件之前,这个时候你可能需要先删除UIGrid组件,然后再添加CenterOnChild组件,再添加UIGrid组件,再把UIGrid对象重新赋值给Checkbox的Checkbox Control Component中的target中。

实现窗口旋转的功能:

添加控制按钮:

在Panel下创建一空对象(AnchorRight)?给对象添加一Anchor组件(NGUI->Attach a Anchor)设定Side参数为BottonRight?为其添加一Botton元件(NGUI?Create a Widget)

设定窗口Tween旋转动画:

选择WindowRoot?为其添加一TweenRotation组件(Component-> NGUI -> Tween -> Rotation),同时关闭该组件(否则一开始就运行了),设定属性。

为按钮添加播放组件:

选择Button?为其添加ButtonTween组件(Component-> NGUI -> Interaction -> Button Tween),把WindowRoot赋值给该组件的TweenTarget,PlayDirection为Toggle(可以实现翻转,不然用forward只能点一次了,就再也回不去)。注意,播放Animation用ButtonPlayAnimation组件,播放Tween动画用ButtonTween组件