Can I detect if a PackedScene changes?

Godot Version

v4.3.stable.official [77dcf97d8]

Question

I’m writing an editor plugin and was wondering if there was any way to detect if a PackedScene resource changed?

Basically, I have a node marked with @tool which has an @exported parameter of type PackedScene. The user can assign this parameter a scene and the node will use it to affect how it is displayed. If the user were to modify the packed scene and save it, I’d like to be able to detect that so my node can update how it’s being rendered.

I’ve noticed that the PackedScene.instantiate() method accepts a GenEditState parameter. Three of these indicate they have something to do with the editor. The documentation doesn’t explain much, though, so I’m unsure if there is any way to use this to detect if my PackedScene has been changed by someone editing it.

If there is a way to detect a change so that I can regenerate my display, please let me know.

You can periodic check the modified time of the file and compare if matches with the last register of time you have.

That could work. Do you know what the different flags that you pass to instantiate() mean? The docs make no sense to me.

No idea