Files
sbox-public/game/addons/tools/Code/Scene/SceneSource/PrefabFileInspector.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

50 lines
1.2 KiB
C#

using Sandbox.Diagnostics;
using static Editor.Inspectors.AssetInspector;
namespace Editor.Inspectors;
[CanEdit( "asset:prefab" )]
public class PrefabFileInspector : Widget, IAssetInspector
{
Asset asset;
public PrefabFileInspector( Widget parent ) : base( parent )
{
Layout = Layout.Column();
}
PrefabFile resource;
public void SetAsset( Asset asset )
{
ArgumentNullException.ThrowIfNull( asset, nameof( asset ) );
this.asset = asset;
resource = this.asset.LoadResource<PrefabFile>();
Assert.NotNull( resource, $"We couldn't load a resource from {asset.RelativePath} - this indicates that the path is monted in the editor, but not the game." );
Rebuild();
}
void Rebuild()
{
SerializedObject so = TypeLibrary.GetSerializedObject( resource );
so.OnPropertyChanged += x =>
{
resource.StateHasChanged();
};
Layout.Clear( true );
var cs = new ControlSheet();
cs.AddRow( so.GetProperty( nameof( PrefabFile.ShowInMenu ) ) );
cs.AddRow( so.GetProperty( nameof( PrefabFile.MenuPath ) ) );
cs.AddRow( so.GetProperty( nameof( PrefabFile.MenuIcon ) ) );
cs.AddRow( so.GetProperty( nameof( PrefabFile.DontBreakAsTemplate ) ) );
Layout.Add( cs );
}
}