(unity3d游戏开发之使用NGUI制作表单.doc
文本预览下载声明
? ????前几天用NGUI制作了个表单(效果如下图所示),现如今把过程给大家分享一下,具体是参照NGUI自带的第七个Demo制作的,大家可以仔细看看Example 7 - Scroll View (Panel)。
1.jpg (44.85 KB, 下载次数: 0)
下载附件 ?保存到相册
4?天前 上传
1.总体上就是用了Scroll View+Scroll Bar来制作,item对象我用的是button,这样是为了可以点击或者是更方便的处理一些其它事情。至于NGUI的使用这里就不详细说了,大家可以网上查找一些NGUI的教程文档看看。2.点击对象出现被选中现象的颜色变化,这里是直接改变的UIButton的defaultColor的值,取消被选中状态也就是恢复默认的颜色值,直接调用ResetDefaultColor();方法即可。
? ?? ?? ?? ?_secondClickObject.GetComponentUIButton().defaultColor = new Color(21f / 255f, 122f / 255f, 2f / 255f, 1f);
? ?? ?? ?? ?//恢复第一次选中对象默认的颜色
? ?? ?? ?? ?_firstClickObject.GetComponentUIButton().ResetDefaultColor();
[color=rgb(51, 102, 153) !important]复制代码3.双击登入功能的实现,由于NGUI已经封装好了双击事件,所以我们直接调用就行OnDoubleClick();本文出自【狗刨学习网】4.第一次点击对象与第二次点击对象之间的交换是声明了两个点击对象的实例,从而实现两个不同对象之间的来回切换。
? ? /// 判断点击对象
? ? /// /summary
? ? /// param name=item选中的item对象/param
? ? public void SelectItem(GameObject item)
? ? {
? ?? ???//当前选中item对象
? ?? ???GameData.CurrGameObejct = item;
? ?? ???//判断两次选择的对象,第一次选择的,第二次选择的
? ?? ???if (_firstClickObject == null)
? ?? ???{
? ?? ?? ?? ?_firstClickObject = item;
? ?? ?? ?? ?//设置选中对象默认的颜色变化
? ?? ?? ?? ?_firstClickObject.GetComponentUIButton().defaultColor = new Color(21f / 255f, 122f / 255f, 2f / 255f, 1f);
? ?? ?? ?? ?if (_secondClickObject != null)
? ?? ?? ?? ?{
? ?? ?? ?? ?? ? //恢复第二次选中对象默认的颜色
? ?? ?? ?? ?? ? _secondClickObject.GetComponentUIButton().ResetDefaultColor();
? ?? ?? ?? ?? ? _secondClickObject = null;
? ?? ?? ?? ?}
? ?? ?? ?? ?return;
? ?? ???}
? ?? ???else
? ?? ???{
? ?? ?? ?? ?_secondClickObject = item;
? ?? ?? ?? ?//设置选中对象默认的颜色变化
? ?? ?? ?? ?_secondClickObject.GetComponentUIButton().defaultColor = new Color(21f / 255f, 122f / 255f, 2f / 255f, 1f);
? ?? ?? ?? ?//恢复第一次选中对象默认的颜色
? ?? ?? ?? ?_firstClickObject.GetComponentUIButton().ResetDefaultColor();
? ?? ?? ?? ?_firstClickObject = null;
? ?? ???}
? ? }
5.添加界面(如下图所示)
2.jpg (44.57 KB, 下载次数: 0)
下载附件 ?保存到相册
4?天前 上传
6.修改界面(如下图所示)
3.png (356.22 KB, 下载次数: 0)
下载附件 ?保存到相册
4?天前 上传
显示全部