#Limit expensive @tool recalc to edit only (not on launch)

1 messages · Page 1 of 1 (latest)

gritty drift
#

I am making a custom resource @tool that has a somewhat expensive calculation that is ran each time the exports change, and then the result is cached into an @export_storage, but since I am doing this like:

@export var padding: int = 8  :
    set(val):
        padding = val
        if Engine.is_editor_hint():
            refresh_final_asset()

the expensive calculation is ran every time godot starts since the 'load' runs this setter each time.

I can take care of it running once per variable by just debouncing the refresh call, but id rather make it not need to hit this every time i open the project, per asset.

grave flint
#

You could probably get away with using Time.get_ticks_msec() < 1000 or something similar

#

at least if the Time singleton exists in the editor

#

@gritty drift ^

gritty drift
#

oooooh thats actually super clever, ill try that

#

lmao im going to assume that means Time is not available in the editor

grave flint
#

oof

#

hmm

#

What did the check that you wrote look like?

gritty drift
#
if Time.get_ticks_msec() < 750:
    return
#

i dont see how that would cause an infinite loop

grave flint
#

Oh, so Godot just crashed

#

interesting

gritty drift
#

Yep removed those 2 lines externally, and its working again

#

a bit jank but it is what it is, it was a good idea

#

OH wait i know whats causing this, it might not be the time thing

#

ok i fixed it, but the time thing didnt work either, even with the check being 3000

#

10,000 worked, thanks a lot!

grave flint
#

I really love how the fix was "make number bigger"

gritty drift
#

xD its so jank but I don't see anywhere the engine exposes whether a change came from the inspector or the engine loading so it'll have to do

#

oh actually, the editor should expose the currently selected object, maybe i can check that