Static typing without class_name
on every single custom scene
#7279
Closed
SKFrozenCloud
started this conversation in
Scripting
Replies: 1 comment 7 replies
-
How do you propose having a named type without Also what's the problem with having a single line naming your class? You don't have to use named classes, but static typing can't be enforced easily on paths like this because you don't know at compile time what type it is, how could you? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to enforce and use static typing without the need to put
class_name
on every single custom scene.For example:
by putting
class_name CameraModule
in my custom camera scene I can then put in my main scene script:@onready var camera_module := $CameraModule as CameraModule
...which enables me to have autocompleted functions and enforce the static typings from the camera scene.
But that means that even a rock needs a custom class if I want the static typing and autocompletetion:
class_name RockEntity
@onready var rock_entity := $RockEntity as RockEntity
In other words, every single custom scene I create will need a
class_name
! Even a small rock!New Proposal
Be able to write it as:
var rock := $Rock as preload("rock.gd")
Beta Was this translation helpful? Give feedback.
All reactions