-
Notifications
You must be signed in to change notification settings - Fork 250
Apply to Scene for gameobject transform #173
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
base: master
Are you sure you want to change the base?
Conversation
… object transform control
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds "Apply to Scene" functionality for GameObject transform properties when editing during gameplay. The feature allows users to save runtime transform changes back to the editor scene, addressing issue #7296.
Changes:
- Added "Apply Local to Scene" and "Apply World to Scene" options to the GameObject transform control header context menu
- Extended "Apply to Scene" functionality to individual property rows for GameObject properties
- Fixed "Apply to Scene" to only show when the game is running and when not multi-editing
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| GameObjectTransformControl.cs | Adds two new menu options for applying local and world transforms to the editor scene, with validation to ensure single-target editing during gameplay |
| ControlSheetRow.cs | Adds AddGameObjectOptions method to enable "Apply to Scene" for GameObject property rows, and updates AddComponentOptions to check for IsPlaying and multi-edit conditions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| void AddGameObjectOptions( Menu menu ) | ||
| { | ||
| if ( !IsEditingGameObject || property.IsMultipleValues ) | ||
| return; | ||
|
|
||
| var gameobject = EditedGameObjects.FirstOrDefault(); | ||
|
|
||
| // Only show if we're editing in a game session | ||
| var session = SceneEditorSession.Resolve( gameobject?.Scene ); | ||
| if ( session is null || !session.IsPlaying ) | ||
| return; | ||
|
|
||
| // try to find the version of this object in the editor session | ||
| var targetObject = session.Scene.Directory.FindByGuid( gameobject.Id ); | ||
| if ( !targetObject.IsValid() ) return; | ||
|
|
||
| // get a serialized version of this object from that session | ||
| var so = targetObject.GetSerialized(); | ||
| var prop = so.GetProperty( property.Name ); | ||
|
|
||
| // add option to apply this value to that scene | ||
| menu.AddSeparator(); | ||
| var setter = menu.AddOption( "Apply to Scene", "save", () => | ||
| { | ||
| using var scope = session.Scene.Push(); | ||
|
|
||
| using ( session.UndoScope( "Apply to Scene" ).WithGameObjectChanges( targetObject, GameObjectUndoFlags.Properties ).Push() ) | ||
| { | ||
| prop.SetValue<object>( property.GetValue<object>() ); | ||
| } | ||
| } ); | ||
| setter.Enabled = Json.Serialize( prop.GetValue<object>() ) != Json.Serialize( property.GetValue<object>() ); | ||
| } |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is significant code duplication between AddGameObjectOptions and AddComponentOptions methods. Both methods follow nearly identical patterns: checking if editing the right type, validating the session, finding the target object, getting the serialized property, and creating a menu option with enabled state based on JSON comparison. Consider extracting the common logic into a shared helper method to reduce duplication and improve maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with component and gameobject being different types and requiring different functions it gets pretty messy trying to do that, not much of the code can actually be shared
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
fixes #2822
Adds "Apply to Scene" option to gameobject transform control, currently has local and world space split into 2 different options as it seems like there's scenarios where either could be useful.


and also adds it to control rows that edit gameobject properties, specifically the individual rows inside the transform control. Works the same as it does on component properties.
Additionally, apply to scene now no longer shows up if the game isn't running (original intended behavior, broke when SceneEditorSession.Resolve was changed) and also no longer shows up if the property is being multiedited (never really worked with multedit, it would apply changes to only the first property selected which was confusing and almost certainly not what the user would have had intended).