GithubHelp home page GithubHelp logo

breadnone / utk-fluent-extension-for-uitoolkit Goto Github PK

View Code? Open in Web Editor NEW
23.0 2.0 1.0 1.19 MB

A simple fluent extension for UIToolkit in Unity3D.

License: MIT License

C# 100.00%
fluent-api ui uitoolkit unity3d

utk-fluent-extension-for-uitoolkit's Introduction

UTK-Fluent-extension-for-UIToolkit

A simple fluent extension for UIToolkit in Unity3D.
UTK is just a simple c# extension to make working with c# in UIToolkit bearable. You can still use UIToolkit documentation to work with this extension.

Requirement:
Unity 2022.2 and above.

sampleUtk

Example syntaxes:

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

//Or via width / height property
visualElement.Width(100, true).Height(100, true); //Uses boolean overload set to true for Percent/dynamic style

//Chaining  
visualElement.FlexRow().FlexGrow(1).BcgColor(Color.yellow);

//Will always return self can safely be cached when/wherever
var vis = visualElement.Margin(5, true).Padding(12); // sets margin on all sides with dynamic size.  

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

//Returns the parent
var visParent = myParent.AddChild(vis2); 

myChild.AddParent(myParent); //Sets parent from directly from child

//Hex color support
visualElement.BcgColor("#0063B1"); //Invalid hex code, will fallback to Color.clear.

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

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

//Equal to registerCallback<MouseDownEvent>();
visualElement.OnMouseDown(x=> {Debug.Log("Click!");}); 

//All registered events will be unregistered via DetachPanel (Or when removed from hierarchy)

Custom controls made with this extension(available in templates folder)
hXfRpQuBMNHawSiIB9TnSYbDUn5twnOdq7DtujgR FAvrHSn47NZk110dQuMbBBPAuj1OzUmWMNg3EnKN

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.