-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
class_name won't work on built-in scripts #25579
Comments
This is expected. I don't think |
I think it does. Sometimes I have a scene, that will be extended by other scenes and I want to check in code if this other scene extends the first one. I do this using |
I think that built in scripts should not be used much. I use them only if I need to quickly test something. There have been some issues reported about their different behaviour and I am beginning to question how worth it is to keep them. |
Well, that's for a another issue. I like them and just won't use them when not possible (the only case when it's not possible for me is the |
I think it is easy to lose track of where is what when the project grows, but this is just my opinion. @vnen I believe that if builtin scripts are some sort of second class citizens, then it should be clearly stated somewhere. |
That's quite subjective and I would argue the other way: it's cleaner to separate the concerns. When you look at the filesystem it's clear that that scene has a script. The same way it's not good to embed images in a scene. I find it also helpful when I need to edit a script without the Godot editor.
How did you do this before
Probably. Honestly, if it were up to me I would forbid built-in scripts, they give more headaches than it's worth. |
Splitting scripts and scene files is also miles better for use with VCS. A Scene file usually is "mature" pretty quickly in regards to the components inside of it, but the scripts will evolve more often over the lifetime of a project. |
I didn't, I use Godot since it has |
If that is the case, then implementing a warning/error when typing that should be enough to close this issue. |
As I continued to use altitude, I discovered some of the disadvantages of built-in scripts and finally decided that it was advantageous to have separate scenes and GDScript files. The reasons are as follows:
If you use the keyword class_name with the embedded script in the scene, no other scripts can find the class name.
It's built-in the scene. If there is a conflict on the versioning system, you must open and modify the thin file. Of course, the altitude is so designed to be very good for versioning that the internal structure of the thin file is not complicated. But it's a little bit more cumbersome compared to just modifying the GDScript separately. For example, if you want to modify a conflict in an external editor, such as VSCode , the embedded script portion does not apply to Synctax.
Because you depend on the scene, you eventually have to save the script as an external file if you want to import it from another It's not as rare as I thought it would be. |
Godot version:
Godot 3.1 build 8698876
OS/device including version:
Arch Linux
Issue description:
When a
Script.gd
has aclass_name
, it will be reckognized by the engine and can be used later. However, if a script built-in on a Scene has aclass_name
, other scripts won't reckognize it.Steps to reproduce:
class_name
. Example:error(1, 20): Unknown class: 'Item'
Minimal reproduction project:
Built-In class_name.zip
In this project, there's both a Built-in (
class_name BuiltinItem
) and a not built-in (class_name NotBuiltinItem
) scripts. Open theScript.gd
file, you will see the error described above. If you change the extension toNotBuiltinItem
, the error will disappear.The text was updated successfully, but these errors were encountered: