UIToolkit Fluent Extension

Hi, I made a fluent extension for uitoolkit to make working with c# in uitoolkit less painful. The extensions are mostly for setters for the style and purely made 100% in c# with.

Sample syntaxes :

//Set width & height property of VisualElement
visualElement.Size(100, 100); //Pixel based size

//Parenting. set parent flex in the end (AddChild will return the parent)
myParent.AddChild(vis1).AddChild(vis2).AddChild(vis3);
var visParent = myParent.AddChild(vis2); //Returns the parent

//Rounded Corners + border
visualElement.RoundCorner(12, true).Border(12, Color.white);


//All events starts with `On`.. e.g: OnMouseEnter, OnFocusOut, OnPointerEnter
myTextField.OnValueChanged(x=>{Debug.Log(x.newValue);});
//Equal to RegisterValueChanged<T>.
visualElement.OnMouseDown(x=> {Debug.Log("Click!");});
//Equal to registerCallback<MouseDownEvent>();

It may not be everybodys cup of tea, but making simple things much easier with it especially for customEditors, well, at least for me.

~cheers

1 Like

That’s a nice extension for building documents in C#

Consider separating the operations on multiple lines for readability:

visualElement
  .RoundCorner(12, true)
  .Border(12, Color.white);

yeah you can do too if you want