Questions tagged [ui-toolkit]

For questions related to the development of UI using UI Toolkit, and its various components, behaviors or problems encountered while using it. UI Toolkit, however is different from the other technologies/components offered by Unity3D such as the uGUI and IMGUI. To avoid confusion please add other appropriate tags such as [unity3d], [mono], [il2cp], [C#], [android], etc.

UI Toolkit is a technology that encompasses a collection of features, functionality, resources, and tools for developing user interfaces (UI) in Unity3D whether to develop custom UI for the Unity Editor or for Runtime UI.

Its development was heavily inspired by the technologies used in web development like Cascading Style Sheets to specify styling choices and markup file to denote the UI structure similar to how its done with HTML on web pages. This helps developers who are more accustomed with web development, transfer a lot of their knowledge to the design of UI in Unity3D.

This technology however is still on its early development stage lacking some of the features offered by uGUI and IMGUI

Questions or problems related to this tag should:

  1. Not be related, in its greatest part, to other UI systems like uGUI, IMGUI or third party components like those found in the asset store.
  2. Be previously checked for syntax problems or mismatch of variable/property names
  3. In case of being related to specifically to the format or style, provide the appropriate markup excerpts from USS and UXML files.
  4. Follow the general Stack Overflow guidelines for asking questions.

Structure


UI toolkit uses UXML(Unity Extensible Markup Language) to indicate the general structure of the UI. It also offers a way to create and modify the structure visually with a Editor GUI, which just writes changes in the UXML for the user.

Some frequently used structure components are Visual Element(a generic container), Label, Button and Slider

Example of a button with the style class "ButtonStyleClass" and a text reading "Click Me!"

<ui:Button name="Button1" class="ButtonStyleClass" text="Click Me!"/>

Style


For style, UI toolkit relies on USS (Unity Style Sheet) which is very similar to how CSS(Cascading Style Sheet) is structured

Heres an example on how to style a text that would align itself at the center, display itself as bold, with a big font size and the font color being blue

.HeaderTextBold{
    align-self: center;
    justify-self: center;
    font-size: 80px;
    -unity-font-style: bold;
    color: rgb(68, 138, 255);
}

To note that a lot of features are lacking from USS that are present in the a modern implementation of CSS. As in the example above(-unity-font-style), some attributes don't share the same nomenclature as standard CSS and some have a different behavior or even properties.

Behaviour

In place of javascript, UI toolkit relies on standard C# scripts to manipulate the UI behaviour. Unity Software provides some examples along with the documentation to help developers reach their objective

uGUI, IMGUI and UI Toolkit


Unity Software offers a comparison web page for developers to better choose which system to rely on when developing UI.

Some confusion is generated due to the nomenclature of these different tools, to note that usually when using UI Toolkit these namespaces are used.

using UnityEngine; 
using UnityEngine.UIElements; 
using UnityEditor;
using UnityEditor.UIElements;

While uGUI uses

using UnityEngine; 
using UnityEngine.UI; 
using UnityEditor;
using UnityEditor.UI;
23 questions
0
votes
0 answers

Can the usage of the UI Document (form the UI Toolkit) without a camera be considered a good practice in Unity?

I'm need a low resolution (pixelated) view for my game and am using a render texture, so the camera isn't rendering anything to the screen/game view. To bring the downscaled view to the player I'm using UI Document with a basic UI Element that has…
0
votes
0 answers

How to detect if InputSystem.EnhancedTouch.Finger is over UI Toolkit Element?

I'm using InputSystem.EnhancedTouch for my game and I have a few buttons that are available through UI Elements. When I click on the UI Elements buttons it activates the InputSystem thus creating a bad experience. I want to filter out all the…
Daniel Tranca
  • 1,374
  • 3
  • 13
  • 23
0
votes
0 answers

How do I bind a float array with Uxml Attribute Description in Unity UI toolkit?

I'm trying to make a custom inspector in Unity which takes in a float[] array and plots it as a line graph. I'm making a BindableElement called "LineGraph2D" to do just that which sits as an element in UI Builder. I think I'm having particular…
maddogedge
  • 23
  • 2
0
votes
0 answers

Unity UiElement created at runtime is not displayed

I created a uielement and gameobject in the runtime and set it to follow the world position of the gameObject. but the uielement is not displayed. I've tried a few things and found a way to display them. public void LateUpdate() { var position =…
0
votes
1 answer

Why can't I install Unity UI Toolkit?

I want to use UI Toolkit for my project. When I try to install it using com.unity.ui something strange happens. When the installation is finished, the package appears and immediately disappears from my manager. I'm using version 2021.3.6f1. Am I…
0
votes
1 answer

Assign UIElements button.clickable, using Visual Scripting Graph

I am trying to use Unity3D's UIToolkit with Visual Scripting Graph... Typically, I can Query for the proper element, and then add the necessary function to the callback... However, as I am new to Visual Scripting, I am not sure how to get to this…
0
votes
0 answers

Unity UI Toolkit: Custom Tool Tip on entering Element shows only the text not the whole UI

I have a problem with my Custom-"Item Tip". When I am with my mouse at the "start of the Tip, it's showing only text and not the whole UI. When I am only in the Inventory Item but not at the Tool Tip: When I am between being in it and not(I changed…
0
votes
3 answers

Touch is not working with Unity UI Toolkit buttons

I'm having a weird issue, may be a simple fix. I've got a UI only "game" using the new UI Toolkit. It's a little kind of a drawing program. I've got a draw area in the middle with "tool buttons" on the sides. Everything works fine with Mouse, Pen,…
KeepCool
  • 497
  • 1
  • 6
  • 24
1
2