mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-15 17:59:22 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
namespace Editor;
|
|
|
|
[CustomEditor( typeof( Angles ) )]
|
|
public class AnglesControlWidget : ControlWidget
|
|
{
|
|
public override bool SupportsMultiEdit => true;
|
|
|
|
public AnglesControlWidget( SerializedProperty property ) : base( property )
|
|
{
|
|
property.TryGetAsObject( out var obj );
|
|
|
|
Layout = Layout.Row();
|
|
Layout.Spacing = 2;
|
|
|
|
TryAddField( obj, "pitch", Theme.Red, "height", "Pitch" );
|
|
TryAddField( obj, "yaw", Theme.Green, "360", "Yaw" );
|
|
TryAddField( obj, "roll", Theme.Blue, "sync", "Roll" );
|
|
}
|
|
|
|
private void TryAddField( SerializedObject obj, string propertyName, Color color, string icon, string tooltip )
|
|
{
|
|
var prop = obj.GetProperty( propertyName );
|
|
if ( prop is null ) return;
|
|
|
|
var control = Layout.Add( new FloatControlWidget( prop ) { HighlightColor = color, Icon = icon, Label = null, ToolTip = tooltip } );
|
|
control.MinimumWidth = Theme.RowHeight;
|
|
control.HorizontalSizeMode = SizeMode.CanGrow | SizeMode.Expand;
|
|
control.MakeRanged( SerializedProperty );
|
|
}
|
|
|
|
protected override void OnPaint()
|
|
{
|
|
// nothing
|
|
}
|
|
}
|