AdvStandaloneInputModule.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.EventSystems;
  4. using UnityEngine.Serialization;
  5. [AddComponentMenu("Event/Adv Standalone Input Module")]
  6. /// <summary>
  7. /// 根据StandaloneInputModule源码修改而来
  8. /// StandaloneInputModule的事件只能发送到触发GameObject或它的父级
  9. ///
  10. /// author : wboy
  11. /// </summary>
  12. public class AdvStandaloneInputModule : PointerInputModule
  13. {
  14. private float m_PrevActionTime;
  15. private Vector2 m_LastMoveVector;
  16. private int m_ConsecutiveMoveCount = 0;
  17. private Vector2 m_LastMousePosition;
  18. private Vector2 m_MousePosition;
  19. private GameObject m_CurrentFocusedGameObject;
  20. private PointerEventData m_InputPointerEvent;
  21. protected AdvStandaloneInputModule()
  22. {
  23. }
  24. [Obsolete("Mode is no longer needed on input module as it handles both mouse and keyboard simultaneously.", false)]
  25. public enum InputMode
  26. {
  27. Mouse,
  28. Buttons
  29. }
  30. [Obsolete("Mode is no longer needed on input module as it handles both mouse and keyboard simultaneously.", false)]
  31. public InputMode inputMode
  32. {
  33. get { return InputMode.Mouse; }
  34. }
  35. [SerializeField]
  36. private string m_HorizontalAxis = "Horizontal";
  37. /// <summary>
  38. /// Name of the vertical axis for movement (if axis events are used).
  39. /// </summary>
  40. [SerializeField]
  41. private string m_VerticalAxis = "Vertical";
  42. /// <summary>
  43. /// Name of the submit button.
  44. /// </summary>
  45. [SerializeField]
  46. private string m_SubmitButton = "Submit";
  47. /// <summary>
  48. /// Name of the submit button.
  49. /// </summary>
  50. [SerializeField]
  51. private string m_CancelButton = "Cancel";
  52. [SerializeField]
  53. private float m_InputActionsPerSecond = 10;
  54. [SerializeField]
  55. private float m_RepeatDelay = 0.5f;
  56. [SerializeField]
  57. [FormerlySerializedAs("m_AllowActivationOnMobileDevice")]
  58. private bool m_ForceModuleActive;
  59. [Obsolete("allowActivationOnMobileDevice has been deprecated. Use forceModuleActive instead (UnityUpgradable) -> forceModuleActive")]
  60. public bool allowActivationOnMobileDevice
  61. {
  62. get { return m_ForceModuleActive; }
  63. set { m_ForceModuleActive = value; }
  64. }
  65. /// <summary>
  66. /// Force this module to be active.
  67. /// </summary>
  68. /// <remarks>
  69. /// If there is no module active with higher priority (ordered in the inspector) this module will be forced active even if valid enabling conditions are not met.
  70. /// </remarks>
  71. public bool forceModuleActive
  72. {
  73. get { return m_ForceModuleActive; }
  74. set { m_ForceModuleActive = value; }
  75. }
  76. /// <summary>
  77. /// Number of keyboard / controller inputs allowed per second.
  78. /// </summary>
  79. public float inputActionsPerSecond
  80. {
  81. get { return m_InputActionsPerSecond; }
  82. set { m_InputActionsPerSecond = value; }
  83. }
  84. /// <summary>
  85. /// Delay in seconds before the input actions per second repeat rate takes effect.
  86. /// </summary>
  87. /// <remarks>
  88. /// If the same direction is sustained, the inputActionsPerSecond property can be used to control the rate at which events are fired. However, it can be desirable that the first repetition is delayed, so the user doesn't get repeated actions by accident.
  89. /// </remarks>
  90. public float repeatDelay
  91. {
  92. get { return m_RepeatDelay; }
  93. set { m_RepeatDelay = value; }
  94. }
  95. /// <summary>
  96. /// Name of the horizontal axis for movement (if axis events are used).
  97. /// </summary>
  98. public string horizontalAxis
  99. {
  100. get { return m_HorizontalAxis; }
  101. set { m_HorizontalAxis = value; }
  102. }
  103. /// <summary>
  104. /// Name of the vertical axis for movement (if axis events are used).
  105. /// </summary>
  106. public string verticalAxis
  107. {
  108. get { return m_VerticalAxis; }
  109. set { m_VerticalAxis = value; }
  110. }
  111. /// <summary>
  112. /// Maximum number of input events handled per second.
  113. /// </summary>
  114. public string submitButton
  115. {
  116. get { return m_SubmitButton; }
  117. set { m_SubmitButton = value; }
  118. }
  119. /// <summary>
  120. /// Input manager name for the 'cancel' button.
  121. /// </summary>
  122. public string cancelButton
  123. {
  124. get { return m_CancelButton; }
  125. set { m_CancelButton = value; }
  126. }
  127. private bool ShouldIgnoreEventsOnNoFocus()
  128. {
  129. switch (SystemInfo.operatingSystemFamily)
  130. {
  131. case OperatingSystemFamily.Windows:
  132. case OperatingSystemFamily.Linux:
  133. case OperatingSystemFamily.MacOSX:
  134. #if UNITY_EDITOR
  135. if (UnityEditor.EditorApplication.isRemoteConnected)
  136. return false;
  137. #endif
  138. return true;
  139. default:
  140. return false;
  141. }
  142. }
  143. public override void UpdateModule()
  144. {
  145. if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus())
  146. {
  147. if (m_InputPointerEvent != null && m_InputPointerEvent.pointerDrag != null && m_InputPointerEvent.dragging)
  148. {
  149. ReleaseMouse(m_InputPointerEvent, m_InputPointerEvent.pointerCurrentRaycast.gameObject);
  150. }
  151. m_InputPointerEvent = null;
  152. return;
  153. }
  154. m_LastMousePosition = m_MousePosition;
  155. m_MousePosition = input.mousePosition;
  156. }
  157. private void ReleaseMouse(PointerEventData pointerEvent, GameObject currentOverGo)
  158. {
  159. ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler);
  160. var pointerUpHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
  161. // PointerClick and Drop events
  162. if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick)
  163. {
  164. AdvExecuteEvents.Execute(pointerEvent, AdvExecuteEvents.onClick);
  165. ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler);
  166. }
  167. else if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
  168. {
  169. ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler);
  170. }
  171. pointerEvent.eligibleForClick = false;
  172. pointerEvent.pointerPress = null;
  173. pointerEvent.rawPointerPress = null;
  174. if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
  175. ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler);
  176. pointerEvent.dragging = false;
  177. pointerEvent.pointerDrag = null;
  178. // redo pointer enter / exit to refresh state
  179. // so that if we moused over something that ignored it before
  180. // due to having pressed on something else
  181. // it now gets it.
  182. if (currentOverGo != pointerEvent.pointerEnter)
  183. {
  184. HandlePointerExitAndEnter(pointerEvent, null);
  185. HandlePointerExitAndEnter(pointerEvent, currentOverGo);
  186. }
  187. m_InputPointerEvent = pointerEvent;
  188. }
  189. public override bool IsModuleSupported()
  190. {
  191. return m_ForceModuleActive || input.mousePresent || input.touchSupported;
  192. }
  193. public override bool ShouldActivateModule()
  194. {
  195. if (!base.ShouldActivateModule())
  196. return false;
  197. var shouldActivate = m_ForceModuleActive;
  198. shouldActivate |= input.GetButtonDown(m_SubmitButton);
  199. shouldActivate |= input.GetButtonDown(m_CancelButton);
  200. shouldActivate |= !Mathf.Approximately(input.GetAxisRaw(m_HorizontalAxis), 0.0f);
  201. shouldActivate |= !Mathf.Approximately(input.GetAxisRaw(m_VerticalAxis), 0.0f);
  202. shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f;
  203. shouldActivate |= input.GetMouseButtonDown(0);
  204. if (input.touchCount > 0)
  205. shouldActivate = true;
  206. return shouldActivate;
  207. }
  208. /// <summary>
  209. /// See BaseInputModule.
  210. /// </summary>
  211. public override void ActivateModule()
  212. {
  213. if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus())
  214. return;
  215. base.ActivateModule();
  216. m_MousePosition = input.mousePosition;
  217. m_LastMousePosition = input.mousePosition;
  218. var toSelect = eventSystem.currentSelectedGameObject;
  219. if (toSelect == null)
  220. toSelect = eventSystem.firstSelectedGameObject;
  221. eventSystem.SetSelectedGameObject(toSelect, GetBaseEventData());
  222. }
  223. /// <summary>
  224. /// See BaseInputModule.
  225. /// </summary>
  226. public override void DeactivateModule()
  227. {
  228. base.DeactivateModule();
  229. ClearSelection();
  230. }
  231. public override void Process()
  232. {
  233. if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus())
  234. return;
  235. bool usedEvent = SendUpdateEventToSelectedObject();
  236. // case 1004066 - touch / mouse events should be processed before navigation events in case
  237. // they change the current selected gameobject and the submit button is a touch / mouse button.
  238. // touch needs to take precedence because of the mouse emulation layer
  239. if (!ProcessTouchEvents() && input.mousePresent)
  240. ProcessMouseEvent();
  241. if (eventSystem.sendNavigationEvents)
  242. {
  243. if (!usedEvent)
  244. usedEvent |= SendMoveEventToSelectedObject();
  245. if (!usedEvent)
  246. SendSubmitEventToSelectedObject();
  247. }
  248. }
  249. private bool ProcessTouchEvents()
  250. {
  251. for (int i = 0; i < input.touchCount; ++i)
  252. {
  253. Touch touch = input.GetTouch(i);
  254. if (touch.type == TouchType.Indirect)
  255. continue;
  256. bool released;
  257. bool pressed;
  258. var pointer = GetTouchPointerEventData(touch, out pressed, out released);
  259. ProcessTouchPress(pointer, pressed, released);
  260. if (!released)
  261. {
  262. ProcessMove(pointer);
  263. ProcessDrag(pointer);
  264. }
  265. else
  266. RemovePointerData(pointer);
  267. }
  268. return input.touchCount > 0;
  269. }
  270. /// <summary>
  271. /// This method is called by Unity whenever a touch event is processed. Override this method with a custom implementation to process touch events yourself.
  272. /// </summary>
  273. /// <param name="pointerEvent">Event data relating to the touch event, such as position and ID to be passed to the touch event destination object.</param>
  274. /// <param name="pressed">This is true for the first frame of a touch event, and false thereafter. This can therefore be used to determine the instant a touch event occurred.</param>
  275. /// <param name="released">This is true only for the last frame of a touch event.</param>
  276. /// <remarks>
  277. /// This method can be overridden in derived classes to change how touch press events are handled.
  278. /// </remarks>
  279. protected void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released)
  280. {
  281. var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject;
  282. // PointerDown notification
  283. if (pressed)
  284. {
  285. pointerEvent.eligibleForClick = true;
  286. pointerEvent.delta = Vector2.zero;
  287. pointerEvent.dragging = false;
  288. pointerEvent.useDragThreshold = true;
  289. pointerEvent.pressPosition = pointerEvent.position;
  290. pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast;
  291. DeselectIfSelectionChanged(currentOverGo, pointerEvent);
  292. if (pointerEvent.pointerEnter != currentOverGo)
  293. {
  294. // send a pointer enter to the touched element if it isn't the one to select...
  295. HandlePointerExitAndEnter(pointerEvent, currentOverGo);
  296. pointerEvent.pointerEnter = currentOverGo;
  297. }
  298. // search for the control that will receive the press
  299. // if we can't find a press handler set the press
  300. // handler to be what would receive a click.
  301. var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler);
  302. // didnt find a press handler... search for a click handler
  303. if (newPressed == null)
  304. newPressed = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
  305. // Debug.Log("Pressed: " + newPressed);
  306. float time = Time.unscaledTime;
  307. if (newPressed == pointerEvent.lastPress)
  308. {
  309. var diffTime = time - pointerEvent.clickTime;
  310. if (diffTime < 0.3f)
  311. ++pointerEvent.clickCount;
  312. else
  313. pointerEvent.clickCount = 1;
  314. pointerEvent.clickTime = time;
  315. }
  316. else
  317. {
  318. pointerEvent.clickCount = 1;
  319. }
  320. pointerEvent.pointerPress = newPressed;
  321. pointerEvent.rawPointerPress = currentOverGo;
  322. pointerEvent.clickTime = time;
  323. // Save the drag handler as well
  324. pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>(currentOverGo);
  325. if (pointerEvent.pointerDrag != null)
  326. ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag);
  327. m_InputPointerEvent = pointerEvent;
  328. UIMgr.Instance.ShowClickEffect(pointerEvent.pressPosition);
  329. }
  330. // PointerUp notification
  331. if (released)
  332. {
  333. // Debug.Log("Executing pressup on: " + pointer.pointerPress);
  334. ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler);
  335. // Debug.Log("KeyCode: " + pointer.eventData.keyCode);
  336. // see if we mouse up on the same element that we clicked on...
  337. var pointerUpHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
  338. // PointerClick and Drop events
  339. if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick)
  340. {
  341. AdvExecuteEvents.Execute(pointerEvent, AdvExecuteEvents.onClick);
  342. ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler);
  343. }
  344. else if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
  345. {
  346. ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler);
  347. }
  348. pointerEvent.eligibleForClick = false;
  349. pointerEvent.pointerPress = null;
  350. pointerEvent.rawPointerPress = null;
  351. if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
  352. ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler);
  353. pointerEvent.dragging = false;
  354. pointerEvent.pointerDrag = null;
  355. // send exit events as we need to simulate this on touch up on touch device
  356. ExecuteEvents.ExecuteHierarchy(pointerEvent.pointerEnter, pointerEvent, ExecuteEvents.pointerExitHandler);
  357. pointerEvent.pointerEnter = null;
  358. m_InputPointerEvent = pointerEvent;
  359. }
  360. }
  361. /// <summary>
  362. /// Calculate and send a submit event to the current selected object.
  363. /// </summary>
  364. /// <returns>If the submit event was used by the selected object.</returns>
  365. protected bool SendSubmitEventToSelectedObject()
  366. {
  367. if (eventSystem.currentSelectedGameObject == null)
  368. return false;
  369. var data = GetBaseEventData();
  370. if (input.GetButtonDown(m_SubmitButton))
  371. ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler);
  372. if (input.GetButtonDown(m_CancelButton))
  373. ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler);
  374. return data.used;
  375. }
  376. private Vector2 GetRawMoveVector()
  377. {
  378. Vector2 move = Vector2.zero;
  379. move.x = input.GetAxisRaw(m_HorizontalAxis);
  380. move.y = input.GetAxisRaw(m_VerticalAxis);
  381. if (input.GetButtonDown(m_HorizontalAxis))
  382. {
  383. if (move.x < 0)
  384. move.x = -1f;
  385. if (move.x > 0)
  386. move.x = 1f;
  387. }
  388. if (input.GetButtonDown(m_VerticalAxis))
  389. {
  390. if (move.y < 0)
  391. move.y = -1f;
  392. if (move.y > 0)
  393. move.y = 1f;
  394. }
  395. return move;
  396. }
  397. /// <summary>
  398. /// Calculate and send a move event to the current selected object.
  399. /// </summary>
  400. /// <returns>If the move event was used by the selected object.</returns>
  401. protected bool SendMoveEventToSelectedObject()
  402. {
  403. float time = Time.unscaledTime;
  404. Vector2 movement = GetRawMoveVector();
  405. if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f))
  406. {
  407. m_ConsecutiveMoveCount = 0;
  408. return false;
  409. }
  410. bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0);
  411. // If direction didn't change at least 90 degrees, wait for delay before allowing consequtive event.
  412. if (similarDir && m_ConsecutiveMoveCount == 1)
  413. {
  414. if (time <= m_PrevActionTime + m_RepeatDelay)
  415. return false;
  416. }
  417. // If direction changed at least 90 degree, or we already had the delay, repeat at repeat rate.
  418. else
  419. {
  420. if (time <= m_PrevActionTime + 1f / m_InputActionsPerSecond)
  421. return false;
  422. }
  423. var axisEventData = GetAxisEventData(movement.x, movement.y, 0.6f);
  424. if (axisEventData.moveDir != MoveDirection.None)
  425. {
  426. ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler);
  427. if (!similarDir)
  428. m_ConsecutiveMoveCount = 0;
  429. m_ConsecutiveMoveCount++;
  430. m_PrevActionTime = time;
  431. m_LastMoveVector = movement;
  432. }
  433. else
  434. {
  435. m_ConsecutiveMoveCount = 0;
  436. }
  437. return axisEventData.used;
  438. }
  439. protected void ProcessMouseEvent()
  440. {
  441. ProcessMouseEvent(0);
  442. }
  443. [Obsolete("This method is no longer checked, overriding it with return true does nothing!")]
  444. protected virtual bool ForceAutoSelect()
  445. {
  446. return false;
  447. }
  448. /// <summary>
  449. /// Process all mouse events.
  450. /// </summary>
  451. protected void ProcessMouseEvent(int id)
  452. {
  453. var mouseData = GetMousePointerEventData(id);
  454. var leftButtonData = mouseData.GetButtonState(PointerEventData.InputButton.Left).eventData;
  455. m_CurrentFocusedGameObject = leftButtonData.buttonData.pointerCurrentRaycast.gameObject;
  456. // Process the first mouse button fully
  457. ProcessMousePress(leftButtonData);
  458. ProcessMove(leftButtonData.buttonData);
  459. ProcessDrag(leftButtonData.buttonData);
  460. // Now process right / middle clicks
  461. ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData);
  462. ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Right).eventData.buttonData);
  463. ProcessMousePress(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData);
  464. ProcessDrag(mouseData.GetButtonState(PointerEventData.InputButton.Middle).eventData.buttonData);
  465. if (!Mathf.Approximately(leftButtonData.buttonData.scrollDelta.sqrMagnitude, 0.0f))
  466. {
  467. var scrollHandler = ExecuteEvents.GetEventHandler<IScrollHandler>(leftButtonData.buttonData.pointerCurrentRaycast.gameObject);
  468. ExecuteEvents.ExecuteHierarchy(scrollHandler, leftButtonData.buttonData, ExecuteEvents.scrollHandler);
  469. }
  470. }
  471. protected bool SendUpdateEventToSelectedObject()
  472. {
  473. if (eventSystem.currentSelectedGameObject == null)
  474. return false;
  475. var data = GetBaseEventData();
  476. ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.updateSelectedHandler);
  477. return data.used;
  478. }
  479. /// <summary>
  480. /// Calculate and process any mouse button state changes.
  481. /// </summary>
  482. protected void ProcessMousePress(MouseButtonEventData data)
  483. {
  484. var pointerEvent = data.buttonData;
  485. var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject;
  486. // PointerDown notification
  487. if (data.PressedThisFrame())
  488. {
  489. pointerEvent.eligibleForClick = true;
  490. pointerEvent.delta = Vector2.zero;
  491. pointerEvent.dragging = false;
  492. pointerEvent.useDragThreshold = true;
  493. pointerEvent.pressPosition = pointerEvent.position;
  494. pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast;
  495. DeselectIfSelectionChanged(currentOverGo, pointerEvent);
  496. // search for the control that will receive the press
  497. // if we can't find a press handler set the press
  498. // handler to be what would receive a click.
  499. var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler);
  500. // didnt find a press handler... search for a click handler
  501. if (newPressed == null)
  502. newPressed = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
  503. // Debug.Log("Pressed: " + newPressed);
  504. float time = Time.unscaledTime;
  505. if (newPressed == pointerEvent.lastPress)
  506. {
  507. var diffTime = time - pointerEvent.clickTime;
  508. if (diffTime < 0.3f)
  509. ++pointerEvent.clickCount;
  510. else
  511. pointerEvent.clickCount = 1;
  512. pointerEvent.clickTime = time;
  513. }
  514. else
  515. {
  516. pointerEvent.clickCount = 1;
  517. }
  518. pointerEvent.pointerPress = newPressed;
  519. pointerEvent.rawPointerPress = currentOverGo;
  520. pointerEvent.clickTime = time;
  521. // Save the drag handler as well
  522. pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>(currentOverGo);
  523. if (pointerEvent.pointerDrag != null)
  524. ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag);
  525. m_InputPointerEvent = pointerEvent;
  526. UIMgr.Instance.ShowClickEffect(pointerEvent.pressPosition);
  527. }
  528. // PointerUp notification
  529. if (data.ReleasedThisFrame())
  530. {
  531. ReleaseMouse(pointerEvent, currentOverGo);
  532. }
  533. }
  534. protected GameObject GetCurrentFocusedGameObject()
  535. {
  536. return m_CurrentFocusedGameObject;
  537. }
  538. }