namespace Sandbox.UI; /// /// Like TextEntry, except just for numbers /// [CustomEditor( typeof( Vector2 ) )] [CustomEditor( typeof( Vector3 ) )] [CustomEditor( typeof( Vector4 ) )] public partial class VectorControl : BaseControl { NumberEntry _x; NumberEntry _y; NumberEntry _z; NumberEntry _w; public VectorControl() { _x = AddChild( "x" ); _y = AddChild( "y" ); _z = AddChild( "z" ); _w = AddChild( "w" ); } public override void Rebuild() { if ( Property == null ) return; // get the vector3 as a so if ( Property.TryGetAsObject( out var so ) ) { _x.Property = so.GetProperty( "x" ); _y.Property = so.GetProperty( "y" ); _z.Property = so.GetProperty( "z" ); _z.Style.Display = _z.Property is not null ? DisplayMode.Flex : DisplayMode.None; _w.Property = so.GetProperty( "w" ); _w.Style.Display = _w.Property is not null ? DisplayMode.Flex : DisplayMode.None; } } }