Files
sbox-public/engine/Sandbox.Tools/Scene/Session/PrefabEditorSession.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

32 lines
720 B
C#

namespace Editor;
/// <summary>
/// Holds a current open scene and its edit state
/// </summary>
class PrefabEditorSession : SceneEditorSession
{
public new PrefabScene Scene => base.Scene as PrefabScene;
public PrefabEditorSession( PrefabScene scene ) : base( scene )
{
scene.SceneWorld.AmbientLightColor = new Color( 0.7f, 0.7f, 0.7f );
scene.Name = scene.Source.ResourceName;
Selection.Add( scene );
}
protected override void OnEdited()
{
if ( Scene is { } prefabScene )
{
var prefab = (PrefabFile)prefabScene.Source;
// write from prefab scene to its jsonobject
// this doesn't save it to disk
prefabScene.ToPrefabFile();
EditorScene.UpdatePrefabInstances( prefab );
}
}
}