diff --git a/Runtime/Scripts/Layout/HorizontalScrollSnap.cs b/Runtime/Scripts/Layout/HorizontalScrollSnap.cs index 365c1a9..9fc2a4c 100644 --- a/Runtime/Scripts/Layout/HorizontalScrollSnap.cs +++ b/Runtime/Scripts/Layout/HorizontalScrollSnap.cs @@ -157,7 +157,12 @@ namespace UnityEngine.UI.Extensions { return; } - _scroll_rect.horizontalNormalizedPosition = 0; + try + { + // Rare instances of Unity bug cause error, adding try to manage it. + _scroll_rect.horizontalNormalizedPosition = 0; + } + catch { } Transform child = _screensContainer.transform.GetChild(index); child.SetParent(null, WorldPositionStays); diff --git a/Runtime/Scripts/Layout/VerticalScrollSnap.cs b/Runtime/Scripts/Layout/VerticalScrollSnap.cs index 4493d8b..2b4fe70 100644 --- a/Runtime/Scripts/Layout/VerticalScrollSnap.cs +++ b/Runtime/Scripts/Layout/VerticalScrollSnap.cs @@ -154,7 +154,12 @@ namespace UnityEngine.UI.Extensions { return; } - _scroll_rect.verticalNormalizedPosition = 0; + try + { + // Rare instances of Unity bug cause error, adding try to manage it. + _scroll_rect.verticalNormalizedPosition = 0; + } + catch { } Transform child = _screensContainer.transform.GetChild(index); child.SetParent(null, WorldPositionStays);