浏览代码

Merge pull request #308 from Unity-Technologies/zxw/fix_input_issue

fix input issue
/main
GitHub 3 年前
当前提交
a77de948
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22
      com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs

22
com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs


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);
}
正在加载...
取消
保存