Skip to content

Allow instantiating scenes without any scripts #107817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryevdokimov
Copy link
Contributor

@ryevdokimov ryevdokimov commented Jun 21, 2025

Closes: godotengine/godot-proposals#12647

This would be useful when need a scene for purely visual elements such as generating thumbnails or creating decorative versions.

We already have the ability the include flags to remove scripts when duplicating, so this just removes the extra step in a performant way.

@ryevdokimov ryevdokimov requested a review from a team as a code owner June 21, 2025 18:53
@KoBeWi KoBeWi added this to the 4.x milestone Jun 21, 2025
@RedMser
Copy link
Contributor

RedMser commented Jun 21, 2025

The functionality seems useful, but I'm unsure about putting it into GenEditState. It's currently an editor-only enum, and you're adding an unrelated entry to it that also has a runtime effect.
Furthermore, it feels like it should be a bitflag like is the case with duplicate, but this is just a regular enum so you couldn't combine this value with others.

I think this needs a proper design proposal first. https://github.com/godotengine/godot-proposals
Simplest solution could be a new flags parameter.

@ryevdokimov ryevdokimov force-pushed the add-no-scripts-instantiate branch from ff912c6 to b7d211f Compare June 21, 2025 20:19
@ryevdokimov
Copy link
Contributor Author

Agreed, I've updated the PR to separate it out and will make a dedicated proposal.

Default instantiation behavior with no special flags.
</constant>
<constant name="INSTANTIATION_NO_SCRIPTS" value="1" enum="InstantiationFlags">
If passed to [method instantiate], the scene will be instantiated without any attached scripts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs should likely mention whether this affects child scenes as well, or only nodes from its own scene. (Same goes for SceneState docs).

@ryevdokimov ryevdokimov force-pushed the add-no-scripts-instantiate branch 2 times, most recently from 276334d to 2cf2042 Compare June 22, 2025 02:20
@ryevdokimov ryevdokimov requested review from a team as code owners June 22, 2025 02:20
@ryevdokimov ryevdokimov force-pushed the add-no-scripts-instantiate branch from 2cf2042 to 35a40e0 Compare June 22, 2025 02:48
@ryevdokimov ryevdokimov force-pushed the add-no-scripts-instantiate branch from 35a40e0 to 77f1538 Compare June 22, 2025 13:33
@Bromeon Bromeon dismissed their stale review June 22, 2025 13:43

Addressed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, this is not needed:

// Note: In most situations, compatibility methods should be registered via ClassDB::bind_compatibility_method().
//       This class is only meant to be used in exceptional circumstances, for example, when Godot's hashing
//       algorithm changes and registering compatibility methods for all affect methods would be onerous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow instantiating scenes without any scripts
5 participants