fix: Null Reference Error on ITransform.SetParent

This commit is contained in:
Syntriax 2024-02-06 12:37:51 +03:00
parent d9660c08b1
commit ed6975bf24
1 changed files with 6 additions and 6 deletions

View File

@ -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;