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]
39 lines
834 B
C#
39 lines
834 B
C#
namespace Editor;
|
|
|
|
[CustomEditor( typeof( Sprite.Frame ) )]
|
|
public class SpriteFrameControlWidget : ControlWidget
|
|
{
|
|
public SpriteFrameControlWidget( SerializedProperty property ) : base( property )
|
|
{
|
|
Layout = Layout.Row();
|
|
|
|
if ( property.TryGetAsObject( out var serializedObj ) )
|
|
{
|
|
Rebuild( serializedObj );
|
|
}
|
|
else
|
|
{
|
|
var newFrame = new Sprite.Frame();
|
|
property.SetValue( newFrame );
|
|
if ( property.TryGetAsObject( out var newSerializedObj ) )
|
|
{
|
|
Rebuild( newSerializedObj );
|
|
}
|
|
}
|
|
}
|
|
|
|
void Rebuild( SerializedObject serializedObj )
|
|
{
|
|
Layout.Clear( true );
|
|
|
|
var prop = serializedObj.GetProperty( nameof( Sprite.Frame.Texture ) );
|
|
var textureControl = ControlSheetRow.CreateEditor( prop );
|
|
Layout.Add( textureControl );
|
|
}
|
|
|
|
protected override void PaintUnder()
|
|
{
|
|
// Do nothing...
|
|
}
|
|
}
|