You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are also some other places that would benefit from a "nameof" operator, but that is a different case.
Describe the problem or limitation you are having in your project
I need to find the name of an arbitrary class given a reference.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Apparently this already exists in get_global_name, but it is not exposed to scripting. Thus, expose it to scripting.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Expose get_global_name to scripting.
If this enhancement will not be used often, can it be worked around with a few lines of script?
We can work around it for GDScript like this:
var result := ""
for global_class in ProjectSettings.get_global_class_list():
if str(global_class["path"]) == script.resource_path:
result = str(global_class["class"])
break
However, that is only for GDScript. The method get_global_name exists in Script, and so it would also work for CSharpScript and any other future - or third party - derived class.
Is there a reason why this should be core and not an add-on in the asset library?
The method get_global_name is in core.
The text was updated successfully, but these errors were encountered:
We can work around it for GDScript like this [...] However, that is only for GDScript. The method get_global_name exists in Script, and so it would also work for CSharpScript and any other future - or third party - derived class.
ProjectSettings.get_global_class_list() should retrieve all registered global classes regardless of its scripting language. So it should already be working with CSharpScript. Maybe I misunderstood what you meant.
Describe the project you are working on
This applies to a couple addons:
There are also some other places that would benefit from a "nameof" operator, but that is a different case.
Describe the problem or limitation you are having in your project
I need to find the name of an arbitrary class given a reference.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Apparently this already exists in
get_global_name
, but it is not exposed to scripting. Thus, expose it to scripting.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Expose
get_global_name
to scripting.If this enhancement will not be used often, can it be worked around with a few lines of script?
We can work around it for GDScript like this:
However, that is only forGDScript
. The methodget_global_name
exists inScript
, and so it would also work forCSharpScript
and any other future - or third party - derived class.Is there a reason why this should be core and not an add-on in the asset library?
The method
get_global_name
is in core.The text was updated successfully, but these errors were encountered: