#Accessing a Resource after setting its @exports in C#

1 messages · Page 1 of 1 (latest)

robust cape
#

Basically i have a resource that, after setting its export variables, it is supposed to perform some extra operations involving those.
But _init() (and the C# constructor) happen before that is set.
Is there any way to perform a call automatically after the loading is done?

fallow jetty
#

_ready()?

robust cape
fallow jetty
# robust cape Resources do not call _ready()

Ah right, forgot.. my bad.

Then create a new function in the Resource (setup() or whatever), and on the node/script that you load the resource, put that setup() into the local _ready()?

robust cape
fallow jetty
#

Otherwise maybe a getter could work? So that when a var is read, it would execute whatever extra steps that are needed.

torn shadow
robust cape
robust cape
#

Update: it doesn't get called at all for some reason

torn shadow
#

It might exclude _init

#

Idk

robust cape
#

I'll just make a git issue about it

torn shadow
robust cape
#

Everything is running fine, even the function i was talking about (atm i have a Tool Node set to run it)
But there are no prints

#

I've just accepted there's no solution. Now here's to hope they eventually implement something to solve this.

shadow moat
#

I'm starting to guess that since it requires to do those extra operations maybe it shouldn't be a resource but a scene?

shell tapir
#

One approach I've used in the past to handle this limitation is to implement lazy initialization of the Resource.

Basically, you set up a method such as:

public void UpdateIfDirty()
{
    if (IsDirty)
    {
         IsDirty = false;
         // Do your initialization.
    }
}

Then call that method in the top of any method/property getter dependent on the initialized data.