Skip to content
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

Add ability to create a new inherited scene from code #90057

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

ryevdokimov
Copy link
Contributor

@ryevdokimov ryevdokimov commented Mar 30, 2024

Closes: #3907

Supersedes: #64217

This is done by adding an inherit parameter to open_scene_from_path()

This will allow plugins to be able to create new inherited scenes, which can enhance user workflows.

@kitbdev
Copy link
Contributor

kitbdev commented Mar 31, 2024

To fix the compilation error, you need to add compatibility method bindings in a new editor_interface.compat.inc file.
I recommend looking at how it was done for editor_plugin in https://github.com/godotengine/godot/pull/88081/files#diff-005a1ef5a7f4fa8db6b115528dbd935d1fc2836bf579c3ceb72f77ad848a4161.
The number at the end of the compat methods should be this PR number, so it would be _open_scene_from_path_90057(const String &scene_path).
The errors should also be added to misc\extension_api_validation\4.2-stable.expected

@ryevdokimov ryevdokimov requested review from a team as code owners March 31, 2024 16:09
@ryevdokimov ryevdokimov force-pushed the fix-inherit2 branch 2 times, most recently from c5f7f93 to 52c716a Compare March 31, 2024 16:16
@ryevdokimov ryevdokimov changed the title Add inherit parameter to open_scene_from_path Add ability to create a new inherited scene from code Apr 1, 2024
@ryevdokimov ryevdokimov force-pushed the fix-inherit2 branch 3 times, most recently from 472b636 to 58007d6 Compare April 4, 2024 21:16
Copy link
Contributor

@passivestar passivestar left a comment

Choose a reason for hiding this comment

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

Tested, it works. I managed to make a button that creates an inherited scene from gltf at the same path like so:

var path = EditorInterface.get_selected_paths()[0]
var new_path = path.get_basename() + ".tscn"
var main_scene_path = EditorInterface.get_edited_scene_root().scene_file_path
EditorInterface.open_scene_from_path(path, true)
EditorInterface.save_scene_as.call_deferred(new_path, false)
EditorInterface.open_scene_from_path.call_deferred(main_scene_path)

@ryevdokimov ryevdokimov force-pushed the fix-inherit2 branch 2 times, most recently from fd87766 to 77a57cb Compare August 15, 2024 23:54
@ryevdokimov ryevdokimov force-pushed the fix-inherit2 branch 2 times, most recently from 8535a0f to bc395fa Compare September 19, 2024 04:38
Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

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

I wonder if the name of the name parameter should be make_inherited instead. But I can also see that it's called this way for consistency with the internal methods. Either way it's fine.

<description>
Opens the scene at the given path.
Opens the scene at the given path. If [param set_inherited] is [code]true[/code], a new inherited scene will be created.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Opens the scene at the given path. If [param set_inherited] is [code]true[/code], a new inherited scene will be created.
Opens the scene at the given path. If [param set_inherited] is [code]true[/code], a new inherited scene is created.

or

Suggested change
Opens the scene at the given path. If [param set_inherited] is [code]true[/code], a new inherited scene will be created.
Opens the scene at the given path. If [param set_inherited] is [code]true[/code], creates a new inherited scene.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2nd one sounds good.

@ryevdokimov ryevdokimov requested a review from a team as a code owner December 5, 2024 22:13
@ryevdokimov
Copy link
Contributor Author

Rebased to fix 4.3-stable.expected conflict.

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Dec 14, 2024
@akien-mga akien-mga merged commit f7f2361 into godotengine:master Dec 14, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

Add a method to create a new inherited scene from code
7 participants