Skip to content

Conversation

@boxrocket6803
Copy link
Contributor

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.
image
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.
image

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).

Copilot AI review requested due to automatic review settings January 13, 2026 20:16
Copy link
Contributor

Copilot AI left a 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.

Comment on lines 334 to 366
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>() );
}
Copy link

Copilot AI Jan 13, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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

johncosfm and others added 2 commits January 13, 2026 14:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply to scene action for transform

2 participants