https://github.com/ltmx/unity.uitoolkit.extensions
Extension Methods to better build UI through code using Unity UIElements
https://github.com/ltmx/unity.uitoolkit.extensions
ui-library ui-toolkit unity unity-editor unity-editor-gui unity-engine unity-gui unity-plugin unity-ui unity-uielements
Last synced: 9 months ago
JSON representation
Extension Methods to better build UI through code using Unity UIElements
- Host: GitHub
- URL: https://github.com/ltmx/unity.uitoolkit.extensions
- Owner: ltmx
- License: mit
- Created: 2024-02-13T18:27:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-15T10:53:52.000Z (over 1 year ago)
- Last Synced: 2025-04-07T02:07:56.350Z (10 months ago)
- Topics: ui-library, ui-toolkit, unity, unity-editor, unity-editor-gui, unity-engine, unity-gui, unity-plugin, unity-ui, unity-uielements
- Language: C#
- Homepage:
- Size: 60.5 KB
- Stars: 23
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Unity.UIToolkit.Extensions
Extension Library for Unity UIElements




[](https://unity3d.com)
## Create UI using LINQ Syntax
Looks :
```cs
public static TextField CreateInputTextField(this VisualElement container)
{
var row = container.Row();
row.Image().USS("logo");
var inputTextField = row.TextField()
.Multiline(true)
.Value(AthenaSettings.DefaultPrompt)
.ToolTip("[Shift + Enter] to SEND\n[Esc] to STOP chat")
.Placeholder("Type your message here")
.HidePlaceholderOnFocus(true);
return inputTextField;
}
```
# Install
Unity > Package Manager > Install via Git URL > paste `https://github.com/ltmx/Unity.UIToolkit.Extensions.git`
### Dependencies (automaticaly installed)
- [com.unity.mathematics](https://docs.unity3d.com/Packages/com.unity.mathematics@1.3/manual/index.html)
- [com.unity.modules.uielements](https://docs.unity3d.com/Manual/UIElements.html) (built in package)
# Examples
### Create Child Elements
```cs
element.Button();
element.TextField();
element.Label();
```
### Styling
```cs
element.USS("my-style");
element.RemoveUSS("my-class");
element.ClearUSS("my-class");
element.WhereClassListContains("my-class");
element.FirstElementWithClass("my-class");
// of course everything links together
myButton.WhereClassListContains("unity-text-element").ClearUSS();
```
## An example of how I create a Path Field
```cs
public PathField(string name) : base(name)
{
var button = new ActionButton(OpenPathInExplorer)
.USS("open-button")
.FlexShrink(1)
.FlexGrow(1)
.AlignSelf(Align.Center)
.Margin(0)
.MarginRight(8)
.Size(24)
.BackgroundSize(BackgroundSizeType.Contain);
Insert(1, button);
}
```