From e7e35e8366c2eb5c78e54a0dfac4f55640e7b016 Mon Sep 17 00:00:00 2001 From: "Alfonso J. Ramos" Date: Mon, 18 Dec 2023 14:56:24 +0100 Subject: [PATCH] Expose `Script.get_global_name()` --- core/object/script_language.cpp | 2 ++ doc/classes/Script.xml | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 3b274ecc2f2..0b2d5e41cfc 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -138,6 +138,8 @@ void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("get_base_script"), &Script::get_base_script); ClassDB::bind_method(D_METHOD("get_instance_base_type"), &Script::get_instance_base_type); + ClassDB::bind_method(D_METHOD("get_global_name"), &Script::get_global_name); + ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal); ClassDB::bind_method(D_METHOD("get_script_property_list"), &Script::_get_script_property_list); diff --git a/doc/classes/Script.xml b/doc/classes/Script.xml index 28d763585d3..fa8e4ef5f27 100644 --- a/doc/classes/Script.xml +++ b/doc/classes/Script.xml @@ -24,6 +24,27 @@ Returns the script directly inherited by this script. + + + + Returns the class name associated with the script, if there is one. Returns an empty string otherwise. + To give the script a global name, you can use the [code]class_name[/code] keyword in GDScript and the [code][GlobalClass][/code] attribute in C#. + [codeblocks] + [gdscript] + class_name MyNode + extends Node + [/gdscript] + [csharp] + using Godot; + + [GlobalClass] + public partial class MyNode : Node + { + } + [/csharp] + [/codeblocks] + +