From ed6975bf243abc275724209d212560e0f313a531 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Tue, 6 Feb 2024 12:37:51 +0300 Subject: [PATCH] fix: Null Reference Error on ITransform.SetParent --- Engine.Core/Transform.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Engine.Core/Transform.cs b/Engine.Core/Transform.cs index 394c788..fff0636 100644 --- a/Engine.Core/Transform.cs +++ b/Engine.Core/Transform.cs @@ -127,13 +127,13 @@ public class Transform : ITransform return; ITransform? previousParent = Parent; - if (Parent is not null) + if (previousParent is not null) { - Parent.RemoveChild(this); - Parent.OnPositionChanged -= RecalculatePosition; - Parent.OnScaleChanged -= RecalculateScale; - Parent.OnRotationChanged -= RecalculateRotation; - Parent.OnParentChanged -= NotifyChildrenOnParentChange; + previousParent.RemoveChild(this); + previousParent.OnPositionChanged -= RecalculatePosition; + previousParent.OnScaleChanged -= RecalculateScale; + previousParent.OnRotationChanged -= RecalculateRotation; + previousParent.OnParentChanged -= NotifyChildrenOnParentChange; } Parent = transform;