-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script.resource_name always contains blank string #13358
Comments
Run this demo, resouce_name will not print anything, but resource_path is print the right path |
Is resource name used at all internally? Otherwise the field should just be removed |
If you look at the script on the Inspector, you'll see that the resource name is empty. Since GDScript files contain only code, not metadata, it'll never save the resource name even if you set it. This is not the same for other types of resources, so it may be useful for those. I don't know what you are expecting to get from the |
Hmmm, If I remember correctly. I want to get the resource_name of the script to know if the node is Player or Enemy. So basically I have Script character_controller, then Player and Enemy inherit from it. But I found a solution, I can set_meta() to know what is the node type exactly. |
|
I can't check right now, but I think built-in scripts do use |
@mhilbrunner I'm not sure. #14774 uncomments a line that would fix this, but I'm not sure why it was commented out in the first place. |
The plan for 3.2 is to outright get rid of |
So are we still getting rid of it for 3.2 or moved to 4.0? |
4.0 I guess, there is little need to break compat in 3.2 for it as it's only cosmetic. |
I would actually prefer that If it's removed, these resources would instead wind up looking like this: As you can see, it's considerably more difficult to remember which resource is which, as I'm just memorizing some index on some array (which I'm probably not going to do and instead I'll wind up opening each resource one by one to get an idea of that resource's contents.) I could just save each resource to disk to give them a name but the idea here is to not clutter the file system with these little resources (as there's going to be hundreds of them in this game, and all they really do is provide some name and description.) I think it would be better to make it clear in |
I make use of resource_name to figure out what Material I am looking at. If you remove this I would have to parse resource_path to try and infer the material name and if no resource_path then I would need to get shader_param texture path and parse that and extract the name from there. I would actually prefer the ability to (optionally) set resource_name on any game resource. |
As a side note, I'm surprised that the |
So it turns out I was mistaken, It is however only needed in specific cases so it's normal that most resources don't have it filled. The documentation already makes this clear, so we can close this. |
Yeah, this sort of morphed into a proposal. |
Operating system or device, Godot version, GPU Model and driver (if graphics related):
a26b36b
Issue description:
Whenever you try to .get_script().resource_name, the variable only contains blank string. However resource_path always return valid path.
Steps to reproduce:
print(get_script().resource_name)
The text was updated successfully, but these errors were encountered: