From 7924d643e53a1371836f3e3ec65e706d315f53e9 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Fri, 25 Feb 2022 01:10:02 +0100 Subject: [PATCH] Add `includeInternal` to C# NodeExtensions and fix get_child documentation Node methods in C# extended to use generics now have the optional parameter `includeInternal` like their non-generic equivalents. Also, fixed a typo in the `Node.get_child` documentation. --- doc/classes/Node.xml | 2 +- .../Core/Extensions/NodeExtensions.cs | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index d38a724d399..8aeb80e7e0a 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -241,7 +241,7 @@ Returns a child node by its index (see [method get_child_count]). This method is often used for iterating all children of a node. Negative indices access the children from the last one. - If [param include_internal] is [code]true[/code], internal children are skipped (see [code]internal[/code] parameter in [method add_child]). + If [param include_internal] is [code]false[/code], internal children are skipped (see [code]internal[/code] parameter in [method add_child]). To access a child node via its name, use [method get_node]. diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs index 1dc21b6303b..e9d8b983447 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/NodeExtensions.cs @@ -93,8 +93,12 @@ namespace Godot /// Negative indices access the children from the last one. /// To access a child node via its name, use . /// - /// + /// /// Child index. + /// + /// If , internal children are skipped (see internal + /// parameter in ). + /// /// /// Thrown when the given the fetched node can't be casted to the given type . /// @@ -102,9 +106,9 @@ namespace Godot /// /// The child at the given index . /// - public T GetChild(int idx) where T : class + public T GetChild(int idx, bool includeInternal = false) where T : class { - return (T)(object)GetChild(idx); + return (T)(object)GetChild(idx, includeInternal); } /// @@ -113,15 +117,19 @@ namespace Godot /// Negative indices access the children from the last one. /// To access a child node via its name, use . /// - /// + /// /// Child index. + /// + /// If , internal children are skipped (see internal + /// parameter in ). + /// /// The type to cast to. Should be a descendant of . /// /// The child at the given index , or if not found. /// - public T GetChildOrNull(int idx) where T : class + public T GetChildOrNull(int idx, bool includeInternal = false) where T : class { - return GetChild(idx) as T; + return GetChild(idx, includeInternal) as T; } ///