|
|
|
|
|
|
|
|
|
|
UIWidgetsInputMode _inputMode; |
|
|
|
|
|
|
|
static UIWidgetsPanel _currentActivePanel = null; |
|
|
|
|
|
|
|
void _convertPointerData(PointerEventData evt, out Vector2? position, out int pointerId) { |
|
|
|
position = _inputMode == UIWidgetsInputMode.Mouse |
|
|
|
? _getPointerPosition(Input.mousePosition) |
|
|
|
|
|
|
|
|
|
|
void Input_OnEnable() { |
|
|
|
_inputMode = Input.mousePresent ? UIWidgetsInputMode.Mouse : UIWidgetsInputMode.Touch; |
|
|
|
Focus(); |
|
|
|
UnFocus(); |
|
|
|
} |
|
|
|
|
|
|
|
void Input_Update() { |
|
|
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
private bool isActivePanel => _currentActivePanel == this; |
|
|
|
|
|
|
|
public void Focus() { |
|
|
|
_currentActivePanel = this; |
|
|
|
} |
|
|
|
|
|
|
|
public void UnFocus() { |
|
|
|
if (_currentActivePanel == this) { |
|
|
|
_currentActivePanel = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!isActivePanel) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var e = Event.current; |
|
|
|
if (e.isKey) { |
|
|
|
_wrapper.OnKeyDown(e: e); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void OnPointerDown(PointerEventData eventData) { |
|
|
|
Focus(); |
|
|
|
_convertPointerData(eventData, out var pos, out var pointerId); |
|
|
|
_wrapper.OnPointerDown(pos, pointerId); |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void OnDrag(PointerEventData eventData) { |
|
|
|
Focus(); |
|
|
|
_convertPointerData(eventData, out var pos, out var pointerId); |
|
|
|
_wrapper.OnDrag(pos, pointerId); |
|
|
|
} |