public static void ReParent(this Godot.Node child, Godot.Node newParent) { // NOTE: Currently it seems to do it so that it fires _EnterTree and _Ready again when its reparented... // maybe we don't want that? child.GetParent().RemoveChild(child); newParent.AddChild(child); }
public static T GetParentOfType <T>(this Godot.Node node) where T : Godot.Node { Godot.Node parentCandidate = node.GetParent(); while (parentCandidate != null && parentCandidate != node.GetTree().GetRoot()) { if (parentCandidate is T match) { return(match as T); } parentCandidate = parentCandidate.GetParent(); } return(null); }