Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 8c179b4

Browse files
authored
Merge pull request #377 from UnityTech/master
hotfixes
2 parents 2cd5b7e + 08b338e commit 8c179b4

File tree

6 files changed

+47
-5
lines changed

6 files changed

+47
-5
lines changed

Runtime/editor/editor_window.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,33 @@ namespace Unity.UIWidgets.editor {
1515
#if UNITY_EDITOR
1616
public abstract class UIWidgetsEditorWindow : EditorWindow, WindowHost {
1717
WindowAdapter _windowAdapter;
18-
18+
19+
static readonly List<UIWidgetsEditorWindow> _activeEditorWindows = new List<UIWidgetsEditorWindow>();
20+
21+
[InitializeOnLoadMethod]
22+
static void _OnBaseEditorWindowLoaded()
23+
{
24+
EditorApplication.quitting += () =>
25+
{
26+
foreach (var editorWindow in _activeEditorWindows) {
27+
editorWindow.OnDisable();
28+
}
29+
30+
_activeEditorWindows.Clear();
31+
};
32+
}
33+
1934
public UIWidgetsEditorWindow() {
2035
this.wantsMouseMove = true;
2136
this.wantsMouseEnterLeaveWindow = true;
37+
38+
_activeEditorWindows.Add(this);
39+
}
40+
41+
void OnDestroy() {
42+
if (_activeEditorWindows.Contains(this)) {
43+
_activeEditorWindows.Remove(this);
44+
}
2245
}
2346

2447
protected virtual void OnEnable() {
@@ -404,7 +427,7 @@ void _doOnGUI(Event evt) {
404427
-evt.delta.y * this._devicePixelRatio,
405428
evt.mousePosition.x * this._devicePixelRatio,
406429
evt.mousePosition.y * this._devicePixelRatio,
407-
InputUtils.getMouseButtonKey(evt.button)
430+
InputUtils.getScrollButtonKey()
408431
);
409432
}
410433
else if (evt.type == EventType.DragUpdated) {

Runtime/gestures/binding.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ evt is PointerDragFromEditorReleaseEvent
109109

110110
void _handlePointerScrollEvent(PointerEvent evt) {
111111
this.pointerRouter.clearScrollRoute(evt.pointer);
112+
if (!this.pointerRouter.acceptScroll()) {
113+
return;
114+
}
112115

113116
HitTestResult result = new HitTestResult();
114117
this.hitTest(result, evt.position);

Runtime/gestures/pointer_router.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public void removeRoute(int pointer, PointerRoute route) {
2525
this._routeMap.Remove(pointer);
2626
}
2727
}
28+
29+
public bool acceptScroll() {
30+
return this._routeMap.Count == 0;
31+
}
2832

2933
public void clearScrollRoute(int pointer) {
3034
if (this._routeMap.ContainsKey(pointer)) {

Runtime/service/text_input.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ public TextEditingValue compose(string composeText) {
345345
D.assert(!string.IsNullOrEmpty(composeText));
346346
var composeStart = this.composing == TextRange.empty ? this.selection.start : this.composing.start;
347347
var lastComposeEnd = this.composing == TextRange.empty ? this.selection.end : this.composing.end;
348+
349+
composeStart = Mathf.Clamp(composeStart, 0, this.text.Length);
350+
lastComposeEnd = Mathf.Clamp(lastComposeEnd, 0, this.text.Length);
348351
var newText = this.text.Substring(0, composeStart) + composeText + this.text.Substring(lastComposeEnd);
349352
var componseEnd = composeStart + composeText.Length;
350353
return new TextEditingValue(

Runtime/ui/renderer/common/geometry/path/path.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ internal uiPathCache flatten(float scale) {
102102
return this._cache;
103103
}
104104

105-
var _cache = uiPathCache.create(scale);
105+
var _cache = uiPathCache.create(scale, this._shapeHint);
106106

107107
var i = 0;
108108
while (i < this._commands.Count) {

Runtime/ui/renderer/common/geometry/path/path_cache.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ public uiMeshMesh strokeMesh {
3333
float _miterLimit;
3434
float _fringe;
3535

36-
public static uiPathCache create(float scale) {
36+
uiPath.uiPathShapeHint _shapeHint;
37+
38+
public static uiPathCache create(float scale, uiPath.uiPathShapeHint shapeHint) {
3739
uiPathCache newPathCache = ObjectPool<uiPathCache>.alloc();
3840
newPathCache._distTol = 0.01f / scale;
3941
newPathCache._tessTol = 0.25f / scale;
4042
newPathCache._scale = scale;
43+
newPathCache._shapeHint = shapeHint;
4144
return newPathCache;
4245
}
4346

@@ -49,6 +52,10 @@ public bool canReuse(float scale) {
4952
return true;
5053
}
5154

55+
public bool canSkipAAHairline {
56+
get { return this._shapeHint == uiPath.uiPathShapeHint.Rect; }
57+
}
58+
5259
public override void clear() {
5360
this._paths.Clear();
5461
this._points.Clear();
@@ -57,6 +64,8 @@ public override void clear() {
5764

5865
ObjectPool<uiMeshMesh>.release(this._strokeMesh);
5966
this._strokeMesh = null;
67+
68+
this._shapeHint = uiPath.uiPathShapeHint.Other;
6069
}
6170

6271
public uiPathCache() {
@@ -460,7 +469,7 @@ uiVertexUV _expandFill(float fringe) {
460469

461470
uiList<Vector3> _strokeVertices = null;
462471
uiList<Vector2> _strokeUV = null;
463-
if (aa > 0.0f) {
472+
if (aa > 0.0f && !this.canSkipAAHairline) {
464473
_strokeVertices = ObjectPool<uiList<Vector3>>.alloc();
465474
_strokeUV = ObjectPool<uiList<Vector2>>.alloc();
466475
cvertices = 0;

0 commit comments

Comments
 (0)