浏览代码

Merge pull request #373 from UnityTech/editorfeatures

fix conflict between drag & scroll
/main
GitHub 5 年前
当前提交
f3f3967b
共有 4 个文件被更改,包括 34 次插入1 次删除
  1. 25
      Runtime/editor/editor_window.cs
  2. 3
      Runtime/gestures/binding.cs
  3. 4
      Runtime/gestures/pointer_router.cs
  4. 3
      Runtime/service/text_input.cs

25
Runtime/editor/editor_window.cs


#if UNITY_EDITOR
public abstract class UIWidgetsEditorWindow : EditorWindow, WindowHost {
WindowAdapter _windowAdapter;
static readonly List<UIWidgetsEditorWindow> _activeEditorWindows = new List<UIWidgetsEditorWindow>();
[InitializeOnLoadMethod]
static void _OnBaseEditorWindowLoaded()
{
EditorApplication.quitting += () =>
{
foreach (var editorWindow in _activeEditorWindows) {
editorWindow.OnDisable();
}
_activeEditorWindows.Clear();
};
}
_activeEditorWindows.Add(this);
}
void OnDestroy() {
if (_activeEditorWindows.Contains(this)) {
_activeEditorWindows.Remove(this);
}
}
protected virtual void OnEnable() {

-evt.delta.y * this._devicePixelRatio,
evt.mousePosition.x * this._devicePixelRatio,
evt.mousePosition.y * this._devicePixelRatio,
InputUtils.getMouseButtonKey(evt.button)
InputUtils.getScrollButtonKey()
);
}
else if (evt.type == EventType.DragUpdated) {

3
Runtime/gestures/binding.cs


void _handlePointerScrollEvent(PointerEvent evt) {
this.pointerRouter.clearScrollRoute(evt.pointer);
if (!this.pointerRouter.acceptScroll()) {
return;
}
HitTestResult result = new HitTestResult();
this.hitTest(result, evt.position);

4
Runtime/gestures/pointer_router.cs


this._routeMap.Remove(pointer);
}
}
public bool acceptScroll() {
return this._routeMap.Count == 0;
}
public void clearScrollRoute(int pointer) {
if (this._routeMap.ContainsKey(pointer)) {

3
Runtime/service/text_input.cs


D.assert(!string.IsNullOrEmpty(composeText));
var composeStart = this.composing == TextRange.empty ? this.selection.start : this.composing.start;
var lastComposeEnd = this.composing == TextRange.empty ? this.selection.end : this.composing.end;
composeStart = Mathf.Clamp(composeStart, 0, this.text.Length);
lastComposeEnd = Mathf.Clamp(lastComposeEnd, 0, this.text.Length);
var newText = this.text.Substring(0, composeStart) + composeText + this.text.Substring(lastComposeEnd);
var componseEnd = composeStart + composeText.Length;
return new TextEditingValue(

正在加载...
取消
保存