mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 05:48:07 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
50 lines
1.2 KiB
C#
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 );
|
|
}
|
|
}
|