Files
sbox-public/game/addons/tools/Code/Widgets/ControlWidgets/SpriteFrameControlWidget.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

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