大家好,我是孙广东。
转载请注明出处:http://write.blog.csdn.net/postedit/38922399
更全的内容请看我的游戏蛮牛地址:http://www.unitymanual.com/forum.php?mod=guide&view=my
完整的教程下载地址:http://www.unitymanual.com/thread-26665-1-1.html
5.2 Supported Events
Eventsystem支持大量的事件,而且他们能够进一步定制在用户自己定义的用户编写的 InputModules中。
支持的StandaloneInputModule和 TouchInputModule的事件提供的接口和所实现的接口能够在 MonoBehaviour中实现。假设你有有效的 EventSystem配置的事件会在正确的时间被调用。
•IPointerEnterHandler - OnPointerEnter -Called when a pointer enters the object
•IPointerExitHandler - OnPointerExit - Calledwhen a pointer exits the object
•IPointerDownHandler - OnPointerDown - Calledwhen a pointer is pressed on the object
•IPointerUpHandler - OnPointerUp - Calledwhen 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
•IBeginDragHandler - OnBeginDrag - Called onthe drag object when dragging is about to begin
•IDragHandler - OnDrag - Called on the dragobject when a drag is happening
•IEndDragHandler - OnEndDrag - Called on thedrag object when a drag finishes
•IDropHandler - OnDrop - Called on the objectwhere a drag finishes
•IScrollHandler - OnScroll - Called when amouse wheel scrolls
•IUpdateSelectedHandler - OnUpdateSelected -Called on the selected object each tick
•ISelectHandler - OnSelect - Called when theobject becomes the selected object
•IDeselectHandler - OnDeselect - Called onthe selected object becomes deselected
•IMoveHandler - OnMove - Called when a moveevent occurs (left, right, up, down, ect)
•ISubmitHandler - OnSubmit - Called when thesubmit button is pressed
•ICancelHandler - OnCancel - Called when thecancel button is pressed
•IPointerEnterHandler-OnPointerEnter-当pointer指针进入该对象时调用
•IPointerExitHandler-OnPointerExit- pointer指针退出该对象时调用
•IPointerDownHandler-OnPointerDown-当指针在对象上按下时调用
•IPointerUpHandler-OnPointerUp-pointer指针被释放(原状态为被按下)时调用
•IPointerClickHandler-OnPointerClick-pointer指针在同一对象上按下并释放时调用(单击)
•IBeginDragHandler-OnBeginDrag-拖动对象在拖动開始时调用
•IDragHandler-OnDrag-拖动对象,当拖动正在发生进行时调用
•IEndDragHandler-OnEndDrag-拖动对象拖动完毕时调用
•IDropHandler-OnDrop-对该对象拖动完毕时调用
•IScrollHandler-OnScroll-当鼠标滚轮滚动时调用
•IUpdateSelectedHandler-OnUpdateSelected-在选定的对象上eachtick中调用
•ISelectHandler-OnSelect-当对象成为所选的对象时调用
•IDeselectHandler-OnDeselect-在被选定的对象成为取消被选择时调用
•IMoveHandler-OnMove-移动事件发生时调用(左、右、上、 下等)
•ISubmitHandler-OnSubmit-当按下提交button时调用
•ICancelHandler-OnCancel-当按下取消button时调用
5.3 Raycasters
EventSystem须要一种方法用于检測当前的输入的事件须要发送到什么上。而这由 Raycasters提供的。Raycasters搜索scene返回给定的屏幕的位置上‘most valid’(最有效的)的对象。有几种类型的 Raycasters被提供:
•GraphicRaycaster - Used for UI elements,lives on a Canvas and searches within the canvas
•Physics2DRaycaster - Used for 2D physicselements
•PhysicsRaycaster - Used for 3D physics elements
•GraphicRaycaster-用于 UI 元素。在画布上,画布内搜索
•Physics2DRaycaster-用于为 2D 物理元素
•PhysicsRaycaster-用于为三维物理元素
当一个场景中存在而且启用了Raycaster时。它将被用于EventSystem随时查询InputModule是谁发出的。