What are the enums for instantiate() for?

Godot Version

v4.2.1.stable.official [b09f793f5]


I’m reading Help for instantiate() (link) but instead of getting to understand it better, I am just getting more questions. Also it’s something I can’t just test on my own to get a better understanding of because I don’t know what to test.

For example:

GEN_EDIT_STATE_DISABLED=0 blocks edits to the scene state.

Which scene state (scenes do not have “states” by default as far as I know)? Edits by whom, other scenes?

`GEN_EDIT_STATE_INSTANCE = 1’ provides local scene resources to the local scene.

But… local scene already has access to local scene resources? Otherwise how’d it work?

And ‘GEN_EDIT_STATE_MAIN’ is the same as the previous one but

Only the main scene should receive the main edit state.

What does this even mean and what can it be used for?

…and so on. I have the feeling this might be something useful but the way the Help is written is really not making it obvious.

I see other people were wondering about the same thing too (here for example) but I haven’t found a clear answer anywhere. So, anyone knows what are those enums good for?

The enum value is passed to the instantiate method to instantiate a scene’s node hierarchy.
You can make some decisions which node will know about the contents of the new scene (local, root, parent).

Node instantiate ( GenEditState edit_state=0 ) const

For example you can define which node will get the SceneState object with the information about the newly instantiated scene. This would be a list of resources, nodes, exported and overridden properties, and built-in scripts associated with a scene.
Or you can prevent changes to the scene state by setting the enum value to 0.

The scene state belongs to the packed scene. It’s definition is right above.

Hope this helps!

Is there an example I can study to see what exactly happens when something is instantiated using different options? I can instantiate a few scenes using different options but after that I’m not sure what should I attempt to do with them to see the benefits of these enums.