As the title suggests. I need to make sure that some variables can be loaded after enter has finished executing, not before ready executes. While I could do this manually, I was hoping to simplify the workload by having a custom annotation in the form of
@onready()
Mark the following property as assigned when the Node is ready. Values for these properties are not assigned immediately when the node is initialized (Object._init), and instead are computed and stored right before Node._ready.
@onready myVar: int = 1
@onready var character_name: Label = $Label
Our you could updated them in the _init process.
Ryn
I can’t understand what you mean. What I would like is to have an annotation that has its execution phase in ENTER, not after ENTER ends and before READY executes. It would save me a lot of work, but I didn’t find anything in the documentation that would allow me to customise the implementation of the annotation
@OnReady allocates the variable before the _ready() method, so it’s fully available when _ready() is called.
The _init() method is called before the _ready() so if you need to do stuff before _ready() you can do it there.
I’ve always found @OnReady sufficient to have variable global to the script allocated and setup before _Ready() executes.
Obviously I’m not understanding your needs… Sorry.
Ryn
I need to make sure that some variables are loaded, in the enter phase. @onready is after the end of enter, which has to do with my project code tools, which need to be sliced down to a finer point of loading time. I could actually do this manually in enter, but my preference would be to address it with just an annotation declaration. Otherwise the code gets very fragmented, which distresses me. If there is no such annotation like @inenter. Then I need to declare the variable globally now and then assign the variable in the enter code block. So, my actual idea is to do the declaration and assignment of the variable synchronously, through an annotation like @inenter