鼠标模块

SR点击组件

SRStandaloneInputModule

基本流程

鼠标左右中键,分别对应
mastercontrol0, mastercontrol1, mastercontrol2

构建ButtonState

start=>start: 开始 mousePosition=>operation: 获取光标位置 delta=>operation: 获取位移delta raycast=>operation: 获取Raycast结果 StateForMouseButton=>operation: 获取 mastercontrol0, mastercontrol1, mastercontrol2 按键状态 GetMousePointerEventData=>operation: 构建ButtonState end=>end: 构建结束 start->mousePosition->delta->raycast->StateForMouseButton->GetMousePointerEventData->end

处理按键mastercontrol 0/1/2

按下状态

start=>start: 开始 PointerEventData=>operation: 获取PointerEventData RaycastGameObject=>operation: 获取Raycast到的GameObject buttonData=>operation: 填充buttonData数据 eligibleForClick赋值为true GetSrEventObjectObject=>condition: GameObject上有无注册事件 或事件包含Mouse类型 Down=>operation: 触发Down事件 Click=>operation: 更新点击次数 end1=>end: 退出 end=>end: 执行结束 start->PointerEventData->RaycastGameObject->buttonData->GetSrEventObjectObject GetSrEventObjectObject(yes)->Down->Click->end GetSrEventObjectObject(no)->end1

触发的Down事件依次为
IPointerDownHandler - UnityEngine.EventSystems.IEventSystemHandler.pointerDownHandler
ISRVLPointerDownHandler
最终尝试获取IPointerClickHandler
若其中过程有有返回GameObject, 代表执行成功, 则不继续执行后续事件

释放状态

start=>start: 开始 PointerEventData=>operation: 获取PointerEventData RaycastGameObject=>operation: 获取Raycast到的GameObject Up=>operation: 触发Up事件 ClickHandler=>operation: 尝试获取Click事件GameObject eligibleForClick=>condition: 获取成功 且eligibleForClick为true Click=>operation: 触发Click事件 RaycastGameObjectIsNull=>condition: 射线投射到的GameObject为空 ISRVLPointerClickBlankHandler=>operation: 触发空白点击事件事件 ResetPointerEventData=>operation: 重置PointerEventData信息 end=>end: 执行结束 start->PointerEventData->RaycastGameObject->Up->ClickHandler->eligibleForClick eligibleForClick(yes)->Click->RaycastGameObjectIsNull eligibleForClick(no)->RaycastGameObjectIsNull RaycastGameObjectIsNull(yes)->ISRVLPointerClickBlankHandler->ResetPointerEventData RaycastGameObjectIsNull(no)->ResetPointerEventData ResetPointerEventData->end

尝试触发的事件依次为
IPointerUpHandler - UnityEngine.EventSystems.IEventSystemHandler.pointerUpHandler
ISRVLPointerUpHandler
IPointerClickHandler - UnityEngine.EventSystems.IEventSystemHandler.pointerClickHandler
ISRVLPointerClickHandler
ISRVLPointerClickBlankHandler