博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NGUI基本事件
阅读量:4469 次
发布时间:2019-06-08

本文共 2385 字,大约阅读时间需要 7 分钟。

You can add the following functions to your scripts placed on widgets or in-game objects with a collider, provided they are drawn with a camera that has the script attached:

  • void OnHover (bool isOver) – Sent out when the mouse hovers over the collider or moves away from it.Not sent on touch-based devices.
  • void OnPress (bool isDown) – Sent when a mouse button (or touch event) gets pressed over the collider (with ‘true’) and when it gets released (with ‘false’, sent to the same collider even if it’s released elsewhere).
  • void OnClick() — Sent to a mouse button or touch event gets released on the same collider as OnPress. UICamera.currentTouchID tells you which button was clicked.
  • void OnDoubleClick () — Sent when the click happens twice within a fourth of a second. UICamera.currentTouchID tells you which button was clicked.
  • void OnSelect (bool selected) – Same as OnClick, but once a collider is selected it will not receive any further OnSelect events until you select some other collider.
  • void OnDrag (Vector2 delta) – Sent when the mouse or touch is moving in between of OnPress(true) and OnPress(false).
  • void OnDrop (GameObject drag) – Sent out to the collider under the mouse or touch when OnPress(false) is called over a different collider than triggered the OnPress(true) event. The passed parameter is the game object of the collider that received the OnPress(true) event.
  • void OnInput (string text) – Sent to the same collider that received OnSelect(true) message after typing something. You likely won’t need this, but it’s used by UIInput
  • void OnTooltip (bool show) – Sent after the mouse hovers over a collider without moving for longer thantooltipDelay, and when the tooltip should be hidden. Not sent on touch-based devices.
  • void OnScroll (float delta) is sent out when the mouse scroll wheel is moved.
  • void OnKey (KeyCode key) is sent when keyboard or controller input is used.

Inside your event functions you can always figure out who sent the event (UICamera.currentCamera), RaycastHit that resulted in this event (UICamera.lastHit), as well as the on-screen position of the touch or mouse (UICamera.lastTouchPosition). You can also determine the ID of the touch event (UICamera.currentTouchID), which is ‘-1′ for the left mouse button, ‘-2′ for right, and ‘-3′ for middle.

 

这些事可以直接加在包含ngui组件的gameObject脚本上 翻译待补

转载于:https://www.cnblogs.com/kimmy/p/3693020.html

你可能感兴趣的文章
从Github下拉取Laravel项目的完整步骤
查看>>
潜龙博客地址
查看>>
[VJ][DP]Monkey and Banana
查看>>
javascript基础篇--function类型(上)
查看>>
学习进度条05
查看>>
MySQL配置文件详解
查看>>
小vimer的心得+求primer一个实例问题解答
查看>>
HDU 1010 Temper of the bone(深搜+剪枝)
查看>>
如何使用BAT文件批量运行SQL语句,并保存执行结果
查看>>
JS中==和===的区别
查看>>
python—命名规范
查看>>
CSS- 控制图片显示指定大小 并超过大小自动缩小
查看>>
[转]weui-wxss WeUI for 小程序 为微信小程序量身设计
查看>>
[转]使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【八】——Web Api的安全性...
查看>>
[转] sqlserver 中查看trigger的disabled/enabled情况
查看>>
3.29课·········表单验证和事件
查看>>
多级菜单 menu
查看>>
JS代码将数据导入Excel
查看>>
json数组排序
查看>>
Python通过future处理并发
查看>>