(十九)unity4.6學習Ugui中文文檔-------互動-EventSystem,ugui-eventsystem
大家好,我是孫廣東。 轉載請註明出處:http://write.blog.csdn.net/postedit/38922399
更全的內容請看我的遊戲蠻牛地址:http://www.unitymanual.com/forum.php?mod=guide&view=my
5、EventSystem
EventSystem是一種將基於輸入的事件發送到應用程式中的對象,無論是鍵盤、滑鼠、觸摸或自訂輸入。EventSystem由發送事件的幾個組件共同組成。
Overview
當您將 EventSystem組件添加到一個遊戲對象上,你會發現它並沒有多少暴露的功能時,這是因為 EventSystem本身被設計為一個manager and facilitator(管理和主持)EventSystem模組之間的通訊。
EventSystem的主要作用是,如下所示:
•Manage which GameObject is consideredselected
•Manage which InputModule is in use
•Manage Raycasting (if required)
•Updating all InputModules as required
•管理被選中遊戲對象
•管理正在使用的InputModule
•管理Raycasting(如果需要)
•更新所需的所有 InputModules
Input Modules
輸入的模組是EventSystem表現的主要邏輯怎樣的,它們用於:
•Handling Input
•Managing event state
•Sending events to scene objects.
•處理輸入
•管理事件的狀態
•將事件發送到情境物體。
在同一時間只有一個 InputModule可以在 EventSystem 中處於活動狀態,並且他們必須作為 EventSystem組件的同一遊戲物體上的組件。
Raycasters
Raycasters用於發送確定pointer指標位於什麼上方,對於InputModules使用Raycasters這是常見的,情境配置中用於計算pointing裝置是over。
有 3種情況提供的Raycasters預設存在:
•GraphicRaycaster - Used for UI elements
•2DPhysicsRaycaster - Used for 2D physicselements
•3DPhysicsRaycaster- Used for 3D physics elements
•GraphicRaycaster-用於 UI元素
•2DPhysicsRaycaster-用於為 2D物理元素
•3DPhysicsRaycaster-用於為三維物理元素