Editor/Authoring/GooNumberControlWidgets.cs

Editor UI widgets for float and integer property controls. They subclass FloatControlWidget and IntegerControlWidget to hide step buttons, attach a GooTokenBindingButton, and adjust the line edit size during layout.

Native Interop
using Editor;
using Sandbox;

namespace Goo.Authoring;

[CustomEditor( typeof( float ), NamedEditor = "goo-float" )]
public sealed class GooFloatControlWidget : FloatControlWidget
{
	public GooFloatControlWidget( SerializedProperty property ) : base( property )
	{
		HideStepButtons();
		GooTokenBindingButton.Attach( this );
	}

	void HideStepButtons()
	{
		foreach ( var button in GetDescendants<IconButton>() )
		{
			button.Visible = false;
			button.Enabled = false;
		}
	}

	protected override void DoLayout()
	{
		base.DoLayout();
		LineEdit.Size = new Vector2( Width - LineEdit.Position.x, Height );
	}
}

[CustomEditor( typeof( int ), NamedEditor = "goo-integer" )]
public sealed class GooIntegerControlWidget : IntegerControlWidget
{
	public GooIntegerControlWidget( SerializedProperty property ) : base( property )
	{
		HideStepButtons();
		GooTokenBindingButton.Attach( this );
	}

	void HideStepButtons()
	{
		foreach ( var button in GetDescendants<IconButton>() )
		{
			button.Visible = false;
			button.Enabled = false;
		}
	}

	protected override void DoLayout()
	{
		base.DoLayout();
		LineEdit.Size = new Vector2( Width - LineEdit.Position.x, Height );
	}
}