没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Input delegates are useful for when you want to know about every little bit of pointer input that is sent to your control. This allows you not only to respond to each kind of input immediately, but also allows you to override and micro-manage the control's behavior.
资源推荐
资源详情
资源评论
Unity3d EZGUI Ý”Èëʼþ Using Input delegates
Input delegates are useful for when you want to know about every little bit of pointer input that is sent to your control. This allows you not only to respond to each kind of input immediately, but also allows you to override and micro-manage the control's behavior.
A delegate is a method/function that gets called by another piece of code. You define a delegate function/method and then tell another object to call it under certain circumstances. In this case, we want a control to call our function when it receives pointer input. Since the calling object needs to send certain information to, or expects to receive certain information back from the delegate, the delegate must follow a certain pattern. In the case of EZ GUI input delegates, that pattern looks like this:
void MyDelegate(ref POINTER_INFO ptr)
In other words, it returns no value (void), and accepts a single argument: a POINTER_INFO struct which contains the information about the pointer interacting with the control.
First, we'll define our delegate somewhere in one of our scripts. NOTE: Because of limitations in JavaScript/UnityScript, input delegates must be written in C#.
void MyDelegate(ref POINTER_INFO ptr)
{
// Display a message in the console if
// the pointer is dragged over the control:
if(ptr.evt == POINTER_INFO.INPUT_EVENT.DRAG)
Debug.Log("Dragged!");
}
The above code checks to see if the pointer event (.evt) is a drag event. Now we must tell our control about this delegate for it to be called:
void Start()
{
// Get a reference to our control script:
资源评论
alexyuanlei
- 粉丝: 4
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功