diff --git a/Runtime/Scripts/Utilities/UIExtensionMethods.cs b/Runtime/Scripts/Utilities/UIExtensionMethods.cs index 2b2f10a..3472139 100644 --- a/Runtime/Scripts/Utilities/UIExtensionMethods.cs +++ b/Runtime/Scripts/Utilities/UIExtensionMethods.cs @@ -15,6 +15,10 @@ namespace UnityEngine.UI.Extensions parentCanvas = rt.GetComponentInParent(); if (parentCanvas == null) { + if (parent.parent == null) + { + return null; + } parent = parent.parent.GetComponent(); SearchIndex++; } diff --git a/Runtime/Scripts/Utilities/UILineConnector.cs b/Runtime/Scripts/Utilities/UILineConnector.cs index 6b18000..487dec5 100644 --- a/Runtime/Scripts/Utilities/UILineConnector.cs +++ b/Runtime/Scripts/Utilities/UILineConnector.cs @@ -18,7 +18,11 @@ namespace UnityEngine.UI.Extensions private void Awake() { - canvas = GetComponentInParent().GetParentCanvas().GetComponent(); + var canvasParent = GetComponentInParent().GetParentCanvas(); + if (canvasParent != null) + { + canvas = canvasParent.GetComponent(); + } rt = GetComponent(); lr = GetComponent(); }