【转】UGUI EventSystem
EventSystem
The EventSystem is a way of sending events to objects in the application based on input, be it keyboard, mouse, touch, or custom input. The EventSystem consists of a few components that work together to send events.
Overview
When you add an EventSystem component to a GameObject you will notice that it does not have much functionality exposed, this is because the EventSystem itself is designed as a manager and facilitator of communication between EventSystem modules.
The primary roles of the EventSystem are as follows:
- Manage which GameObject is considered selected
- Manage which InputModule is in use
- Manage Raycasting (if required)
- Updating all InputModules as required
Input Modules
An input module is where the main logic of how you want the EventSystem to behave lives, they are used for
- Handling Input
- Managing event state
- Sending events to scene objects.
Only one InputModule can be active in the EventSystem at a time, and they must be components on the same GameObject as the EventSystem component.
If you wish to write a custom input module it is recommended that you send events supported by existing UI components in Unity, but you are also able to extend and write your own events as detailed in the Messaging System documentation.
Raycasters
Raycasters are used for sending figuring out what the pointer is over, it is common for InputModules to use the Raycasters configured in the scene to calculate what the pointing device is over.
There are 3 provided Raycasters that exist by default:
- GraphicRaycaster - Used for UI elements
- 2DPhysicsRaycaster - Used for 2D physics elements
- 3DPhysicsRaycaster - Used for 3D physics elements
If you have a 2d / 3d Raycaster configured in your scene it is easily possible to have non UI elements receive messages from the InputModule. Simply attach a script that implements one of the event interfaces.
Supported Events
The Eventsystem supports a number of events, and they can be customised further in user custom user written InputModules.
The events that are supported by the StandaloneInputModule and TouchInputModule are provided by interface and can be implemented on a MonoBehaviour by implementing the interface. If you have a valid EventSystem configured the events will be called at the correct time.
- IPointerEnterHandler - OnPointerEnter - Called when a pointer enters the object
- IPointerExitHandler - OnPointerExit - Called when a pointer exits the object
- IPointerDownHandler - OnPointerDown - Called when a pointer is pressed on the object
- IPointerUpHandler - OnPointerUp - Called when a pointer is released (called on the original the pressed object)
- IPointerClickHandler - OnPointerClick - Called when a pointer is pressed and released on the same object
- IInitializePotentialDragHandler - OnInitializePotentialDrag - Called when a drag target is found, can be used to initialise values
- IBeginDragHandler - OnBeginDrag - Called on the drag object when dragging is about to begin
- IDragHandler - OnDrag - Called on the drag object when a drag is happening
- IEndDragHandler - OnEndDrag - Called on the drag object when a drag finishes
- IDropHandler - OnDrop - Called on the object where a drag finishes
- IScrollHandler - OnScroll - Called when a mouse wheel scrolls
- IUpdateSelectedHandler - OnUpdateSelected - Called on the selected object each tick
- ISelectHandler - OnSelect - Called when the object becomes the selected object
- IDeselectHandler - OnDeselect - Called on the selected object becomes deselected
- IMoveHandler - OnMove - Called when a move event occurs (left, right, up, down, ect)
- ISubmitHandler - OnSubmit - Called when the submit button is pressed
- ICancelHandler - OnCancel - Called when the cancel button is pressed
【转】UGUI EventSystem的更多相关文章
- UGUI EventSystem.current.IsPointerOverGameObject(),判断是否进入了UI上
EventSystem.current.IsPointerOverGameObject(); //返回一个布尔值,进入了UI上就返回true,用的时候要 using UnityEngine.Event ...
- Unity3D之UGUI学习笔记(三):EventSystem
在UGUI中,EventSystem实现了所有关于交互方面的功能,和NGUI不一样的地方是,我们终于可以摆脱添加Box Collider了! 下面我们来学习一下. 对于按钮来说,直接有onClick的 ...
- Unity UGUI之Canvas&EventSystem
最近想写一套关于UGUI所有控件的基础使用教程系列,主要是根据本人的使用心得来写的,所以其中可能难以避免会有不正确的地方. 好了进入主题,既然是第一篇,我觉得我有必要先介绍一下UGUI必不可缺的两个组 ...
- UGUI之Canvas和EventSystem
先介绍一下UGUI必不可缺的两个组件:Canvas和EventSystem 事实上在场景中第一次创建UGUI控件的时候,这两个物体都会自动添加到场景中,当然,必不可缺的不是这两个物体,而是他们身上挂载 ...
- UGUI源码之EventSystem
今天研究下UGUI的源码,先从EventSystem入手.EventSystem是用来处理点击.键盘输入以及触摸等事件的. 1.BaseInputModule EventSystem开头声明了两个变量 ...
- (二十二)unity4.6学习Ugui中文文档-------交互-Eventsystem & Binding
大家好,我是孙广东. 转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unityma ...
- UGUI研究院之控件以及按钮的监听事件系统
继续学习,我相信大家在做NGUI开发的时候处理事件都会用到UIEventListener,那么UGUI中怎么办呢?先看UGUI的事件有那些吧 Supported Events The Eventsys ...
- Unity -- EventSystem完全掌握
Event System 组成 系统生成的Event System里面主要有两个Components,分别是Event System和Standalone Input Module. 其中Standa ...
- UGUI代码分析
1.canvas,screen模式和world模式区别:screen的绑定摄像机与canvas相对位置不会改变不可改变canvas,world模式下有个event camera相对位置可改变,canv ...
随机推荐
- 金庸和古龙,Netweaver和微服务,以及SAP Hybris Revenue Cloud
这周Jerry在长沙客户现场待了几天,感谢易总和彩亮的款待.终于有机会和关注这个公众号的一些CRM顾问们进行线下互动,感觉很不错.得知公众号里某些文章帮助顾问们解决了一些工作中的实际问题,我很高兴.感 ...
- Java 集合框架_上
集合框架被设计成要满足以下几个目标. 该框架必须是高性能的.基本集合(动态数组,链表,树,哈希表)的实现也必须是高效的. 该框架允许不同类型的集合,以类似的方式工作,具有高度的互操作性. 对一个集合的 ...
- 2018.2.5 PHP如何写好一个程序用框架
随着PHP标准和Composer包管理工具的面世,普通开发者撸一个框架已经不再是什么难事了. 无论是路由管理.ORM管理.还是视图渲染都有许许多多优秀的包可以使用.我们就像堆积木一样把这些包用comp ...
- preprocessing MinMaxScaler
import numpy as npfrom sklearn.preprocessing import MinMaxScalerdataset = np.array([1,2,3,5]).astype ...
- Servlet 学习小结
一.是什么 是用java编写的服务器端程序.从狭义来讲,servlet是java语言实现的一个接口:广义的servlet是指任何实现了这个servlet接口的类.一般情况下,人们将servlet理解为 ...
- SQL查询出每门课都大于80 分的学生姓名
Course表如下: 查询出每门课都大于80 分的学生姓名有两种方法. 1.select distinct name from Course where name not in (select di ...
- Load事件中控件Focus()无效解决办法
原因:Load窗体时,窗体未显示 解决:1.Focus()之前添加this.Show(); 2.在Shown事件中添加Focus()
- nodejs 实现图片上传
1.首先在目录下的运行cmd,执行以下命令 npm install multer; 2.在router下新建upload.js let express = require('express');let ...
- 【图论】[USACO]控制公司 Controlling Companies
玄妙的搜索 题目描述 有些公司是其他公司的部分拥有者,因为他们获得了其他公司发行的股票的一部分.(此处略去一句废话)据说,如果至少满足了以下三个条件之一,公司A就可以控制公司B了: 公司A = 公司B ...
- MySQL的备份与恢复理解与备份策略
MySQL的备份主要分为逻辑备份和物理备份 逻辑备份 在MySQL中逻辑备份的最大优点是对各种存储引擎都可以用同样的方法来备份.而物理备份则不同,不同的存储引擎有着不同的备份方法.Mysql中的逻辑备 ...