Skip to content

Commit 55114e4

Browse files
committed
Fixed an issue with UI recognition breaking when StandardLayer is disabled (#259).
1 parent 9e496a9 commit 55114e4

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

Source/Assets/TouchScript/Scripts/Layers/StandardLayer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,11 @@ private IEnumerator lateEnable()
265265
private void OnDisable()
266266
{
267267
if (!Application.isPlaying) return;
268-
if (inputModule != null) inputModule.INTERNAL_Release();
268+
if (inputModule != null)
269+
{
270+
inputModule.INTERNAL_Release();
271+
inputModule = null;
272+
}
269273
if (TouchManager.Instance != null) TouchManager.Instance.FrameStarted -= frameStartedHandler;
270274
}
271275

Source/Assets/TouchScript/Scripts/Layers/UI/TouchScriptInputModule.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,17 @@ public virtual void ProcessUpdated(object sender, PointerEventArgs pointerEventA
492492
var press = pointer.GetPressData();
493493
if (press.Type != HitData.HitType.UI) continue;
494494
}
495-
else
496-
{
497-
// Don't update the pointer if it is not over an UI element
498-
if (over.Type != HitData.HitType.UI) continue;
499-
}
500495

501496
PointerEventData data;
502497
GetPointerData(pointer.Id, out data, true);
498+
499+
// If not over an UI element this and previous frame, don't process further.
500+
// Need to check the previous hover state to properly process leaving a UI element.
501+
if (over.Type != HitData.HitType.UI)
502+
{
503+
if (data.hovered.Count == 0) continue;
504+
}
505+
503506
data.Reset();
504507
var target = over.Target;
505508
var currentOverGo = target == null ? null : target.gameObject;

0 commit comments

Comments
 (0)