#š§°āui-toolkit
1 messages Ā· Page 24 of 1
when I record video using mobile that element will appear but not relate to unity or my game
is not part of unity it relate to my mobile itself
Great, then the issue is probably just that the framerate isn't high enough and you are feeling the delay in comparison to the hardware cursor
https://gamedev.stackexchange.com/questions/148535/dragging-ui-element-lags-behind-the-cursor it's the same issue you can see on PC
really so 30 FPS not enough to follow the button very fast ?
It's not just framerate, it's also the delay of the entire process from Unity polling the input to the time it's rendered.
Also, doing your positioning in LateUpdate may be introducing a single frame delay, I would do it at the end of Update as afaik UITK does some updating in PreLateUpdate (UpdatePanels; then it calls RepaintPanels in PostLateUpdate)
That makes sense , Thanks mate
Though due to how you're collecting the position from an event you'll also have to make sure you're setting the position after that
Hey, is there a way to detect if the mouse is over a UI toolkit button (my goal is being able to move the user when clicking on the screen, except when i'm over some UI)
You can use Pointer Event
All UI Element have Pointer down and Pointer UP event when Pointer down create bool and set to true , and Pointer Up set to false and on another script that handle user movement check that bool before any other action
I solved same issue like that
I'll have a look at that thanks
That is more clear instead using Pointer Event
does UITK have support for inline elements in text?
like, say, I have a checkbox that I want to sit inside text, that I also want to respect word wrapping behavior
basically what <span> does, or, display: inline-block
I tried to find something on this, but couldn't, then tried to find a way to hack it in, but good lord uitk does not give you a lot of glyph information
I feel like there has to be a way?
There isn't sadly
I would consider allocating that space using a sprite and then trying to pull the text layout info and absolute positioning your element at that position
that was gonna be my fallback but it seems ridiculously complicated to even get just that information
it's possible to get vertex data, but not glyph data
so the closest I can get is to like,, read the vertices and check the UVs to see if they line up with my dummy sprite, which seems violently hacky š
yeah they don't make it easy, back in the day before rich text support I split colored text into hundreds of elements š
how can i fix those Email and password fields do that both input fields are alined
shoud i seperate them or is there any other way
I think the easiest way would be to add some empty spaces in the email label. You could also use use to add some margin to that label.
Hey, I have a problem with my UI buttons. I have a menu system set up that switches between different menus. but when I switch back to the original menu it wont let me click on the buttons anymore. any idea why that would be happening?
thanks
yo, is there any way to detect when a scrollview is moved?
I'm trying to sync a vertical scroll view with a horizontal and vertical view in an editor window
Does databinding work with non scriptable objects?
Basically I'd like to bind the UI to an object, however, the fields may be changing (money, hp, etc).
I thought about using an object with these stuff to bind them.
Is it better to just use a script to update or is there a way to just let an object do it?
You can use any c# object as a data source
https://docs.unity3d.com/6000.3/Documentation/Manual/UIE-runtime-binding-define-data-source.html
In App UI's DI system, is there a way to register instances of a class as a dependency rather than the class itself?
how to curve text in UIdocument
Is there any place which has some visual compilation of what each library element of the UI Toolkit's UI builder look like in a more concise manner than the official unity website ?
This is the best that I've found
https://www.foundations.unity.com/
do ui shaders have per-element instance data?
What am I supposed to do about this? Upgrading older UITK project in Unity 6
I wanted to share this here, too, because I'm interested in how useful (or not) having modern MVVM architecture support (with source generators, analyzers and code fixes) would be for Unity UI Toolkit ... my motivation for creating this plugin was to make my NoesisGUI workflow reach parity with .NET Core/WPF, but I figure this could also be used easily by other frameworks ... it is, after all, used by WPF, UWP, Uno, Avalonia, MAUI and all sorts of UI frameworks.
It's kinda there already in App UI
https://docs.unity3d.com/Packages/com.unity.dt.app-ui@2.2/manual/mvvm-intro.html
I know that package exists.
I really made the plugin for NoesisGUI, which is based on WPF, and using the same .NET ecosystem libraries and tooling consistently makes things a lot more portable and flexible. I'm just curious if anyone will find a use for it other than Noesis.
I believe AppUI is also still a preview package and I've been let down before by Unity abandoning some of these kinds of things ... I guess because it wasn't popular enough.
That reminds me ... I need to check in on if they ever did anything else with the editor node graph/grid package stuff.
Use the UxmlElement attribute instead
Yeah but how? A simple swapout doesn't seem to cut it. I couldn't find docs talking about this replacement
It should cut it, what did you try? What didn't work?
Ok, back to my computer now, you were right, I just didn't realize I wasn't meant to include the <T, U> bits as part of the conversion
@rough scarab actually I was only counting compile errors of which there were none, but after replacing
public class PlayerDefaultWeapon : VisualElement {
public new class UxmlFactory : UxmlFactory<PlayerDefaultWeapon, UxmlTraits> { }
with
public class PlayerDefaultWeapon : VisualElement {
public new class UxmlFactory : UxmlElementAttribute { }
I get the following error in Unity which seems to be a fundamental difference between the factory and element attribute. But I don't know what I'm meant to be replacing exactly
Element 'PlayerDefaultWeapon' is missing a UxmlElementAttribute and has no registered factory method. Please ensure that you have the correct namespace imported. UnityEngine.UIElements.VisualTreeAsset:Instantiate () EditorElement:.ctor () (at Assets/Custom/Tools/DatabaseV2/Editor/Scripts/VisualElements/EditorElement.cs:24) EditorPlayers:.ctor () (at Assets/Custom/Tools/DatabaseV2/Editor/Scripts/VisualElements/Editors/Characters/EditorPlayers.cs:17) MenuCharacters:.ctor () (at Assets/Custom/Tools/DatabaseV2/Editor/Scripts/VisualElements/MenuSecondary/MenuCharacters.cs:12) MenuPrimary:.ctor () (at Assets/Custom/Tools/DatabaseV2/Editor/Scripts/VisualElements/MenuPrimary.cs:22) EWDatabaseEditor:CreateGUI () (at Assets/Custom/Tools/DatabaseV2/Editor/Scripts/EditorWindows/EWDatabaseEditor.cs:40) UnityEditor.EditorWindow:GetWindow<EWDatabaseEditor> (bool,string) EWDatabaseEditor:OpenWindow () (at Assets/Custom/Tools/DatabaseV2/Editor/Scripts/EditorWindows/EWDatabaseEditor.cs:28)
AH, it is meant to be this?
[UxmlElement]
public partial class PlayerDefaultWeapon : VisualElement {
Yeah that's not a straight swap
Yes, you were meant to look at the docs for the attribute, which also link to migration guides
Not just arbitrarily change the factory's base class
Fair, I'm a bit behind many of the UIElements changes I think
I heard there was a way to bind elements to properties of custom POCO classes now? Where can I find out more about that? I have a full system here where I'd implemented a massive workaround for that not being possible about 5 or 6 years back or something. Used to only work for MonoBehaviours or ScriptableObjects or something
?softban 458503201214300170 crypto scam
killmeforfun was softbanned.
Just googling UITookit Binding
https://docs.unity3d.com/6000.3/Documentation/Manual/UIE-data-binding.html
on screen radar
somehow when i click on any visual element it counts as selected when checking if (EventSystem.current.currentSelectedGameObject != null)
on buttons i also set selectable to false, yet it also counts as selected.
this creates some annoying behavior when i click on a button and then want to catch keyboard input again, because now my keyboard input is blocked because a gameobject is selected.
is there any way to make button presses not select the object in the eventsystem?
seems like no matter what ui element i click it grabs the input focus onto the ui.
somehow when i press enter or escape in an input field it still remains selected in the "ui navigation", so it still counts as a textfield that is selected.
so i cannot check if the player is currently typing in the ui, because even if they finished typing into a field it still is focused.
man this drives me nuts š
there is a way to disable navigation
should have it on every UI component I believe
? where is that from?
should be in the inspector for the input field component?
are talking about ui toolkit?
what i did now was to handle submit/cancel events and send them to the event system to deselect the ui when they are pressed.
oh it might be different, I assumed it would work the same
maybe there is a navigation field/property you can disable via code?
i don't think so š there's the focusController but it doesn't help.
USS Hot-Reload can sometimes be a Hot Mess Express. Spent an hour fighting with some niche complicated state issue when hot-reloading
how would i make a container that is designed for specific base dimensions say 1920x720 then stretch horizontally when it gets wider and stretch vertically when it gets narrower?
better yet if it could maintain base width instead of height below a certain treshold for example 4/3
Hello, I am new to Unity and I would like to achieve this one simple thing: I have created a menu with UI builder, this was very simple - I have three images and I would like to initiate animation from sprites for each image on hover. Is there any way how to easily run the sprite animation on hover?
You can use the visual element scheduler to run sprite animations
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/UIElements.IVisualElementScheduler.html
Thank you, I will try that too. Also would like to ask about the approach how to do the menu in the best way, lets consider that I want to have MainMenu and Settings screens. I think it is better to have only ONE UIDocument that has two elements: MainMenu and Settings. Is this a better way to keep all parts of main menu together?
If you want to pop open the settings menu at any time during gameplay, then you might want to keep them as separate documents.
Yes, but when I open menu in game, it should open whole menu, not even settings, except the "new game" button will be different, but I presume this can be handled by code
hey all, has anyone ever seen bugs with ui toolkit when using a material on a visualelement? things like flickering, degenerate triangles, etc.?
i just recently implemented a tick shader that looks like this, but now i'm getting situations where this happens. it's happening reliably on multiple machines
happens for a single frame and then disappears, this is just one of the artifacts, there are many
really having trouble figuring out root cause of this. if anyone has any ideas, pls lmk. a bit at a loss here
i want to ask do you use world space ui toolkit for that healthbar or UGUI?
world space ui toolkit
i've removed all UGUI from my project and i've gone full UI toolkit with shadergraph. however now i'm getting these artifacts and it's driving me nuts
the biggest isuse is that i can't friggin catch them and pause the app so that i can take a proper frame snapshot through the frame debugger. if there was a way i could stop the app when i get these artifacts, it would be great but i don't actually know what's causing this, just have hunches about what it could be
this might not work but it could be something simple like increasing render scale in URP asset the one you use for project .
actually i have my render scale set to 50%. could that be contributing to artifacts?
actually on my 4090 i have render scale set to 100% so it's unlikely to be the root cause
is there a paid service for unity where you can get official support?
"Success Plans" but i think its for teams and also not sure if you need unity pro for it
$450/yr for individual creators. might be worth it.
for now i'm choosing to ignore it since i was able to find some parts of the UI where i was doing NaN operations
ah crap i need a unity pro license. it's $2.3k/yr...
What Unity version are you using? Because there's certainly some fixes for artifacts https://issuetracker.unity3d.com/issues/severe-visual-artifacts-on-the-worldspace-label-text-on-a-specific-project
But yours specifically may not be one of them
6000.3.4f1
omg
well, that fix is in 6000.3.5f1, so it may help at least
!!!!!!!
There's no command called
!!!!!!.
hmmm i looked at the bug and it's actually a worldspace UI. i'm using a screen space UI toolkit with world space calculations. so not exactly the same thing
hey just a heads up that i'm actually not using worldspace ui toolkit. i'm doing screen space ui toolkit but making worldspace calculations
sigh... unfrotuantely, it did not fix it.
ahh , so that is why it is so sharp and clean
thanks for heads up i was bashing my head on the wall last night
I know you said youāve tested on multiple machines already but how different are they? Have you tried on a different platform?
Also, is the big ass triangle in the second image supposed to be there?
Iām assuming the big triangle with the alpha blending in the first image is supposed to be there? Is that one working as intended?
I had a graphical bug once which took me a while, it was a non-Unity webgl app where only one of my devices would get an entirely black screen. If I remember right it was whenever the browser used d3d. The issue was due to a fragment shader outputting invalid colour values which caused d3d to just black out the screen (probably because it was rendering a full screen texture). The problem went away by forcing the browser to use OpenGL and it was fixed completely by clamping the values in the fragment shader to 0-1 or whatever. Thing is on OpenGL and on other devices like Mac and iOS browser there was no visible issue at all so it took a while to nail down ..
I thought it was an interesting issue but maybe itās just because I hadnāt ran into it before
they're about the same
metal and directx share the same bug, which makes me think it's a code problem but i'm unsure what i tis
i stopped looking into this and took a break from game dev, getting back to it now
if only i could catch the frame, but it's been almost impossible. i can make the problem happen almost immediately when it's running at full speed but i've spent hours trying to get it to happen on a frame by frame basis and it doesn't happen
i believe i may have found the root cause because it's no longer happening. i was feeding bad positions to a health chunk feature that i was creating at runtime (when enemies take damage), specifically NaN, so that could have been why
goddamn it... i saw the artifact for a split second š¢
Have you looked for every possible source of a divide by zero?
This sounds like some kind of timing or race condition
Also you could try purposefully putting NaNs into it to see if you can cause the problem to happen intentionally
it's fixed i think
i had to go through every single dynamically generated visual element and make sure i wasn't passing NaN, it was an absolute pain but i think i've got them all
and yes, i had a couple divide by zeros in my tick shader that i addressed last week but that was also a reason why i was getting artifacts
So what exactly was the issue? NaNs in a vertex shader causing misplaced triangles? I havenāt seen this happen before so it would be good to know for sure
How do you change the color of the underline of the selected tab?
It keeps happening. Iām going to ignore it for now because itās not very often. But Iāll definitely have to fix it eventually. It always feels like I got it but then it reappears during gameplay. I was able to get it frame perfect in a step by step but the step did not cause the triangle to freeze in place
As with anything else, use USS selectors.
There's multiple guides to styling that's pinned
I tried that with the :active psuedo class and all other classes but nothing really changed
i was able to change the color of the whole underline when i remove the psuedo class name
but to be able to change only the active one gave back no result
.unity-tab__header-underline:active{
color: rgb(255, 255, 153);
background-color: rgb(255, 255, 153);
text-color: rgb(255, 255, 153);
}
that's not the selector you can see it uses in the debugger
thanks that worked
Can UIToolkit shaders sample the framebuffer? Can we finally have blurry backgrounds?
i tried this and no
in general i'm finding that using materials with UI Toolkit really f'ing sucks
i had to disable my tick material because it was causing huge amounts of artifacts
just a heads up that disabling the custom material i was using for resource bar ticks made things more stable and i'm seeing the artifacts a lot less
i could potentially split off the nameplates into its own UI document but ui toolkit is really screwing me here with the material implementation
i'm just gonna have to drop to uGUI for the nameplates
i am learning unity and now i want to learn UI but there i have two options Unity IU or UI toolkit which one i go with ??
https://docs.unity3d.com/6000.3/Documentation/Manual/UI-system-compare.html
UI Toolkit has a bit of a learning curve. It's not as drag and drop as uGui but I think it's way more flexible and customizable.
Oh no problem in learning bcz its like html and css a little bit so thats easy for me
You need to figure out what makes them drop to zero, anything else has high chance of being placebo since you donāt have a good way to measure it
At some point in your project you will have added something that started causing it - try going back to that point (either with version control or just disable objects/scripts you added)
Once youāve found out what you can remove to get the thing to stop entirely, you know that the issue must reside within the stuff you removed. Then you can keep adding things back in one by one and narrow down where the root cause of the issue is. If you figure out that the issue is some kind of āin some situations this thing might be NaN but rarelyā try modifying it to always produce NaN and see if that reliably causes the same issue. Eventually youāll figure out specifically what is causing it and then you can figure out what to do to fix it, which at that point will probably be simple
Also, sometimes you may think āit wasnāt happening at the point in time when I did this partā when actually the issue was present by that time (you just happened to get lucky and the problem didnāt occur at the time), so you spend forever trying to figure it out because youāre working with an invalid assumption of which parts could possibly be the problem
Iāve had bugs before where the actual bug was some foundational underlying issue, but then features added later exacerbated it and misled me into thinking the problem was definitely within those new features - removing them makes everything seem better but doesnāt address the thing causing it.
Imagine something like causing a 1ms sleep in every object which does an Update, and you donāt notice because you have like 3 objects, but then later when you add a feature with 20 objects and your project grinds to a halt - you would have a hard time figuring out whatās wrong if you assume everything was fine before those 20 objects
Not sure if thatās helpful here but Iāve learned that 99% of the confusing bugs I find are caused by me assuming something else is working when it isnāt, so itās the first thing I think of when I find some weird problem that doesnāt make sense
Experienced with IMGUI and Canvas stuff and want to get comfortable with UI Toolkit; Just curious, is it productive/not psycho at all to want to avoid all the css esque programming and ui building tools and just handle everything through my own c# utils and data solutions?
The big appeal for me going to ui toolkit is just avoiding being tied to the canvas and gameobject/component based solution, the actual web based workflow thatās usually a benefit isnāt interesting to me currently
You can do everything in code if you want to. Only down side is having to go into play mode to view your changes
Hey, I'm trying to apply a custom font to a panel using a Panel Text Settings, but the font isn't applying. Am I doing something wrong anywhere? I don't quite understand, I expected the entire panel fonts to be changed to mine, but isn't
Is it because of the Path? Where the font asset is at is in "Assets/UI Toolkit/Resources/Fonts & Materials/Zen_Kaku_Gothic_New"
Is that Resources path correct? Or is it because its nested inside its own font folder instead of being right under Fonts & Materials?
According to the documentation:
You can edit the paths to store the font assets, sprite
assets, custom style sheets, and the color gradient presets. The paths must be a sub-folder of a Resources folder. Create a Resources folder if you donāt have one in your project.
Default Font AssetAfter you create a font asset from a font file, you must place it in the path set to store all the font assets.
Property Description
Default Font Asset Default font to use when you create a new text object.
Path Path to store all the font assets.
Here, I just edited the ui real quick to show whats the font supposed to be, by directly assigning it to a label element
Does this not work because the default USS overrides it?
I removed the import of the default USS and now instead of using the actual font its using the font asset...
However, you canāt change the default UITK Text Settings for Editor UI in the current release.
... I guess this is what's wrong
how do you set up ui buttons from ui toolkit to do actions?
like teleporting a player to scenes etc
You can use the Button.clicked event
thank you champ
Why scroll view doesn't shrink to fit the screen?
I've always avoided UIs but is it normal that I can see the entire canvas in the game tab even when the game isn't started?
Yes. It's a good way to preview what the game will actually look like
but I mean everything on the canvas, the menu, also the debug menu, the crosshair cube before the math
Yea. some of that doesn't run until play mode. Like lists wont have any content
so it's normal, thanks for clarifying
Is there a convention on how to make a pointer visual with UIElements instead of using the Cursor object?
Seems like uss is the way to change the cursor while over an element
https://docs.unity.cn/Manual/UIE-USS-SupportedProperties.html#cursor
Based on in runtime UI, you must use a texture for custom cursorsI assume that using an absolute VisualElement instead of a Cursor is a bad idea.(
It's not a terrible idea if you wanted to do like a fake mouse cursor with a gamepad. Like some consoles game do.
I do! I just unsure how. Probably, a separate block at the root level with absolute position and .PlaceInFront() that contains a visual element I need to move. Just a visual element with an absolute position seems unreliable.
running into this really weird issue where a particular period is causing my label to think it has another line
- with . there's a phantom newline
- without . there is no phantom newline
- with .. it creates a newline and also has correct bounding box. this is in 6.3
anyone know whether there is a fix for this?
is there something equivalent to eventsystem's PhysicsRaycaster/2D in ui toolkit? i googled a bit but didn't find anything and made some dirty hack that sort of works for one event, but is duplicating this over number of events i need the "happy path" to do interaction with colliders in ui toolkit?
There is a Panel Raycaster not sure if does what you want though
unless i misunderstood what it does- panel raycaster goes into the opposite direction - when the EventSystem wants to raycast into the ui toolkit panels, the functionality of PhysicsRaycaster was that a camera that you put the component on was now handling raycasting input events into 2d/3d colliders - you could put a collider+monobehavior that implements IPointerDownHandler and mouse clicks that didn't land on ui components would execute a callback on that interface, similar to what the snippet above does, so that you can for example click a cube and in the callback open a context menu
or is the idea that you run eventsystem together with the ui toolkit? š¤
I was pretty sure you can use the same eventsystem but now I'm second guessing myself
Are you trying to click through a UI visual element to a gameobject? or to click on like a worldspace UI
click on worldspace objects, like click a cube with collider(trigger) -> the cube gets an event callback, in event system flow it was as simple as a physicsraycaster on the camera that does the raycast and a script on the cube collider gameobject, with ui toolkit i'm a bit confused as the docs are pretty slim, i tried cajoling ais to find a solution but they all suggest manual raycasting like in the snippet is the way to go (also they hallucinate non existent apis pretty badly in this part of unity)
although i should mention the issue isn't the manual raycasting, just the convenience of it - eventsystem handled filtering the event through the UIs first, so a click event on the object would be blocked by UI as a user would normally expect
ok, so you want to click on an object and then have it send an event to a UI toolkit visual element?
no, in the other direciton, have the ui toolkit handle clicks, filter the event through it's event handlers, and trigger callback on the front most gameobject provided it has a trigger on it, the same as eventsystem does it, but i'm sorta convinced there's just no api to do it in ui toolkit
oh i see. I think the best you could do would be to have the ui call ExecuteEvents.Execute<IPointerDownHandler>() ir whatever your custom handler is
yea the manual part of it isn't the problem - the snippet above does it for 1 event, but i'd have to duplicate it a few times to handle the other events, which is super weird
guys im creating a online figma stylie unity ui toolkit editor, you can exports your design
Not sure if this is a silly question but trying to learn UI Toolkit and wanted to setup a MultiColumnListView. The example in the docs uses Binding in order to populate stuff but right now my data is stored in a struct, Is there a way for me to set this up with just c# and the struct or do i need to involve a scriptableobject or something in order to create a serializedobject
the ListView doc example has you setup funcs and actions to do this kinda thing which would be more than fine for me
I think the 2022.3 version of the page is giving me what im looking for
amazing documentation
With some extensions I've ended up with this which i think is pretty clean
Vis_Project.AddSheet(proj.Songs).Add<ScriptableSong>
(
((180, "Track Title"), (e, i) => e.AddLabel(i.PrimaryName)),
((50, "Object"), (e, i) => e.AddObject(i))
);
public static void Add<T>(this MultiColumnListView input, params((int, string), Action<VisualElement, T>)[] values)
nested tuples a little cursed tho
What's the equivalent of EditorGUI.indentLevel for UIToolkit stuff?
It's a Foldout š
has Unity announced any plans to bring UI Shader Graph to HDRP?
i saw this example in the ui toolkit intro page, how would i actually make a dynamic pie chart?
Hi,
Do you suggest to use SVG or PNG in UI Toolkit for creating in-game UI/UX ?
Also what do you suggest about the resolution ? For example if the reference resolution is 1080x1920, I should export them all in high resolution like 512x512 and after adding them to the canvas, reside them to the actual size on UI for better performance and overall size ?
If you have simple shapes svgs can be very beneficial because they size dynamically and do not care about resolution.
As for exports you have to take multiple things into consideration:
- Which resolution can you optimize for? Many people now have QHD monitors (2560x1440), while 4k is niche and could increase file size for a tiny userbase
- How big will your image realistically be displayed? A full screen intro logo needs a bigger export than that small checkmark you display on a button somewhere (SVGs dont care about size that much though because you can just scale them up without quality loss)
Is there a way to bind the height of this visual element to the width of the entire document, such that the visual element can be a square that resizes with the width of the document, but not the height?
Hi,
Is there any way to access properties of custom UXML (template) after drag and drop it into the UI Builder ? (And don't break it by unpacking)
Or it is not a good approach at all ?
Im reviewing a PR for one of my developers about the UI toolkit, and something hes doing doesnt seem quite right to me. We need an animated icon that rotates to show that something is loading. Can someone confirm for me that apply a StyleRotate via the scheduler to the raw style is the best way to accomplish this? It seems a bit weird to me
I presume RawStyle is a weird custom method for .style, but I'd personally use Rotate/Angle and not a Quaternion. But what you have there works fine.
_image.style.rotate = new Rotate(Angle.Turns(turns += turnRate));
So thats a fine way to do it? I was concerned that it should use the transition system or something else, as it seems odd to me to have the scheduler manually adjust the rotation of a visual element every frame
there's no continuous transition, so you'd have to constantly add and remove a class to achieve the same thing
Ah, gotcha. Then it makes sense
We hired a proper web dev to help us out with the UI toolkit stuff. Me and the other senior dev build some really nice infrastructure for him to work with, but some of the stuff he does seems insane to me
The product has never looked better though
Any thoughts ?
Right click on the template and Open it either in context or in isolation
https://docs.unity3d.com/6000.3/Documentation/Manual/UIB-structuring-ui-templates.html
It is for changing the template itself, is it right ? It means, changing the children affect all the instances.
I believe so yea. If you want to adjust that particular instance, the easiest way would be to use a USS class
I see, thanks. I was looking for a way to avoid using USS class for changing children properties of a template.
What's wrong with using child selectors?
Nothing wrong about them, It was clearer in my mind to change a template instance child properties directly instead of using selectors. (Probably it is because I didn't have enough knowledge about UI Toolkit concept)
Hey guys! Really dumb question here but I'm a beginner with the UI toolkit: how do I make it so two elements overlap rather than share space?
I want the little 'front' semicircle to go on top of the speed-dial, both of them are on the speedometer-back, but I can't figure out how to get them to overlap
Just wanted a vibe check on common practice, if I have this red rect and want the content to consume eg. half the space of it as it's doing, it's fine to achieve this by giving it a empty element as a sibling and messing with growth and basis right?
just not sure if it's common to use empties for padding or if ideally i'm meant to just play around with the settings in the red element or just the content element inside of it
So I am noticing that on mobile all elements that are in a scroll view flicker when the scroll is moving via inertia. Anyone encountered this ?
in worlview pannel seetings i can't click any buttons and cannot intract not even cs RegisterCallback<ClickEvent> works
I'm looking around, for colors in UI Toolkit, is there only RGB? No other color spaces like OkLab. No way to define gradients either
Yea only RGB and RGBA you can the Painter2D with a gradients
Well I was talking more about defining the colors and then using the colors mainly in text
There are gradients in text too. But still just RGB
Oh I see, I forgot I checked this page 2 weeks ago. Thanks
Hi,
Is there anyway to achieve outward aligned outline instead of UI Toolkit center-aligned outline for texts ?
Hi,
Is there any way to get Canvas Size (Screen size) of root UXML inside custom control ?
btw, I could get it in this way, though I don't know if there is a better way.
private VisualElement GetRoot()
{
VisualElement current = this;
while (current.parent != null)
{
if (current.parent.name == "document")
{
return current.parent;
}
current = current.parent;
}
return current;
}
Hi,
I want to know if there is a way to set text of Label element inside template in UI Builder ? Or I have to write a script to do that ?
Another question,
Is there any way to drag and drop a template inside another template by UI Builder ?
Next question,
Is there any way to change selector order (precedence) ? Or choose specific selector for specific field ?
I would appreciate it if anyone could help me with them.
/// <summary>
/// Gets the root of the current hierarchy.
/// </summary>
public static VisualElement GetRoot(this VisualElement element)
{
if (element.panel != null)
return element.panel.visualTree;
VisualElement topMostRootContainer;
for (topMostRootContainer = element; topMostRootContainer.parent != null; topMostRootContainer = topMostRootContainer.parent) {
}
return topMostRootContainer;
}
(the point is the fast-path through panel)
jumpscared by untraditional for loop
I've tried that but it returns UI Builder panel.
Ah, I don't use UI Builder, sorry
I see. That code I use, doesn't look good but it returns root correctly in both UI Builder and Game view.
Anyway, do you have any idea about my other questions ?
Selector precedence is as documented https://docs.unity3d.com/Manual/UIE-uss-selector-precedence.html
I read that, I didn't get how to change the order tho. I have 2 selectors in different style sheets. One is .unity-label which is default from Unity and one is local selector in its template. .unity-lable has higher priority but I want the other selector.
can you screenshot the element and its styles in the UI Toolkit Debugger
You mean this ?
Yes, and expand Matching Selectors
You've already got another stylesheet using the same precedence
perhaps you want to increase it by doing something like .unity-label.button-label {
So I have .unity-label in Common.uss. It means, default .unity-label and the one in Common.uss are different ?
different how? In precedence?
Different in any aspect, because I thought for changing the defaults I should create that exact selector then change its values from default values.
Also I couldn't make it work.
It is not recognizable by that label element.
Also note that some of your styles are inlined into the element
Yes, It is because I couldn't use the selector to change them because of this precedence issue I'm facing.
Can you show what happens when you use .unity-label.button-label
Hmm, it was typo
Sorry about that
There shouldn't be a space between the selectors
it should also be unity-label, still has a typo
Hmm, you are totally right. Sorry about that.
It works now. I was surprised why it doesn't work though as you can see I use the same approach above it.
Sorry for wasting your time. But if you have time and desire, could you take a look into my 2 other questions ?
Hmm, still .unity-label has higher priority on padding.
Can you show it in the UITookit debugger, as that shows the precedence, and I have no idea what the builder does
You can see that it's at the bottom of the list, and has therefore is applied after the others
and it also has no mention of padding
Got it, thanks. I thought UI Builder shows the chosen selector next to the field before changing that specific field value. Sorry for bothering.
is there a way to find the associated VisualElement in a treeview given an item ID?
...oh wait it it the [] accessor on the TreeView itself?
(looks like no)
it seems weirdly difficult to navigate treeviews
I can't find a nice way to go from id to index
all the traversal functions seem to take in index rather than id
and the only conversion/traversal thing seems to be to get the root visualelement from an ID, but, visualelements are transient and can be null while off-screen right?
right now I'm looking for a GetParentIdOfId(int id) function but uuuuh idk how to even make one, beyond maintaining my own structure or doing a brute force search
is there something I'm missing?
Working with ui tool kit, it looks/feels very much like early stages of javascript/html/css - and i saw there's a react-unity library for it, how well does it work ? does the added JS engine slows the game much ? is it noticeable ?
anyone mix UITK with uGUI? im familiar with CSS, but a Unity beginner so im thinking of using .uss as the source of truth and having a mechanism/script that converts .uss files into scriptable objects for uGUI components. This is for layout/theming/typography stuff
Freya, you can use a SerializableGuid ?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Me still struggling while UI Toolkit is not working with the Quest3 oof
Which version of Unity are you using? They have been adding more API for stuff like that.
And if you are still looking for answer and using something like Unity 6 or 6.3 I can send a code snippet.
I'm using unity 6, but I could upgrade for this project
There are methods inside the view controller for getting parent ids and one of them sounds like what you are looking for.
I apologize if this is not what you are exactly looking for.
Edit this is in Unity 6
treeview.viewController.GetParentId()
No problem. The view controller holds a lot of the core functionality for certain views.
Mainly finding methods for ids, the index of the items in the collection and so forth. So most of the time if you are needing information about a collection in a visual element built into Unity the view controller has a lot of methods to help out with that.
- TreeViews
- ListViews.
- The new heiarchy in 6.3 has a newer set of functionality for them.
Edit meant to reply to the thanks part for the no problem comment.
gotcha!
I feel like I'm getting the hang of how UXML works. It's quite different to the old GUI, but the more I figure out, the more I start to like it.
I wouldn't have been able to put anything nearly as sleek into the inspector prior to this, nevermind the additional functionality.
In c#, is there a way to style a basefield to how Unity displays it in inspector by default?
eg. this is a default object field vs. a propertyfield bound to a gameobject prefab
i want how the second one looks
(i don't want to use the propertyfield here because other ones have header and space attributes that i don't want to use)
I have never seen this website before and I am glad you randomly dropped a link. This is neat.
It's not very random given that I made it and have been posting it for years lol
Honestly first time I noticed it. Thank you for continously helping the community with resources like that.
why is ui toolkit recommended for editor and custom editor windows
what would be the most important points to mention and what are the main advantages
That would depend on who you are trying to convice
https://docs.unity3d.com/6000.3/Documentation/Manual/UI-system-compare.html
kinda side route to this question, is there a direct way to get/create a propertyfield that ignores unity's attributes like space and header?
i know i can manually make correct fields per type but
Please anyone?
This might be the best you can do at the moment
https://docs.unity3d.com/6000.3/Documentation/Manual/ui-systems/built-in-filters.html
God bless you
I can't create a panel text settings, the fonts don't appear in "Font Asset" field
I tried AIs / tutorials / Generating a font atlas using text mesh pro menu
any ideas ?
it's to fix a really nasty ui toolkit bug that sometimes my users don't have a font for the entire session because I change it using uss and apparently it can fail and there is no fallback
seems like a bug to me, if you load a bad font it should default to a default font
- {
-unity-font-definition: url("project://database/Assets/TextMesh%20Pro/Examples%20&%20Extras/Fonts/BangersXXXXX.ttf");
color: white;
}
So I have a custom visual element Im working with that has a pool of children. When I return a child to the pool, it can rarely be reused in the same frame. Right now, I have an issue where the pseudo states (Hovered, Active, Selected, ect) are not being reset when the object is returned to the pool. When I scroll through said collection, I can end up with 5 or more elements in the hovered pseudo state. I probably forgot something simple to fix this, but I cant track down what it actually is
Perhaps removing it from the hiearchy and then readding it?
Can confirm that removing the item from the hierarchy when pooled fixes this problem.
Doesn't feel like this channel has a lot of help ^^*
The documentation for the editor tooling side is as informative as a unity employees answer to when a feature is being released.
VisualElement: need OnDestroy / single-fire cleanup callback
Hi i wonder if I'm only one person who finds lack of OnDestroy on Visual elements so annoying ? Whenever i write my Custom VisualElement and want this element to subscribe / unsubscribe from external events it is real nightmare. Only way to do it I'm aware of is AttachToPanelEvent DetachFromPanelEvent that are triggered multiple times (it is triggered many times while initlisation). Is there better way to do it ?
Example of code
public partial class ResearchTile : VisualElement
{
public ResearchDefinitionSO Research { get; private set; }
public void Initialize(ResearchDefinitionSO research)
{
Research = research;
RegisterCallback<DetachFromPanelEvent>(OnDetach);
RegisterCallback<AttachToPanelEvent>(OnAttach);
}
private void OnAttach(AttachToPanelEvent evt)
{
if (Research != null)
{
Research.OnUnlocked += UpdateVisual;
Research.OnBecomeResearchable += UpdateVisual;
}
}
private void OnDetach(DetachFromPanelEvent evt)
{
if (Research != null)
{
Research.OnUnlocked -= UpdateVisual;
Research.OnBecomeResearchable -= UpdateVisual;
}
}
}```
Can someone help me?
I can't drag and drop selector to elements in hierarchy and viewport
Unity 6000.0.67f1

I want to have a window/panel like visual element that grows in both axis according to its content/children, it has direction column. Then I want one label in that panel to contribute only to its parent height and not expand in width beyond its parent, but I cant make this label to wrap the text and it always grows horizontaly contributing to panels width. How should I set it up to work like that?
what's the current status quo on getting bloom / glow to work with ui toolkit?
you will run into a lot of issues with UItoolkit
i advice u upgrade to 6.3 latest LTS
that was the only thing that solved all those issues for me
hi guys anyway to blur the background when a ui menu is open?
i know there's a builtin blur filter in 6.3, but right now it's either blurring my UI and not just background or if I move it in the hierarchy, it doesnt blur at all
all these variables show up as editor only (including my own variables); is linking to variables editor-only and I can't do this? or is there something I missed?
(unity 6000.3)
Linking to variables?
sorry, yeah, like this
thanks, i'll try
apparently, FilterFunction.AddParameter only support up to 4 parameters. I have a perlin noise shader that takes in 11 parameters, it's applied to a filterfunction that's attached with a material in the UI template's custom filter, is this the wrong way to supply values from the UI builder into the shader?
this filterfunction asset is used for debugging purposes, but eventually I'll still be sending values using filterFunction.AddParameter(new FilterParameter(myValue)), so it'll be met with the same error
I cannot for the life of me find any existing discussion online about FilterFunctions taking more than 4 parameters, I can't be the first person that tried to add more than 4 parameters to this right
So how would I go about rendering Menu2 behind Menu1 without reversing the hierarchy?
having a really weird issue where on macos, my ui document straight up doesnt render (tried and tested on windows, though). weird quirk: if i go to scene view, it then renders on my game view.
thereafter if i maximize my game view, the ui disappears again. anyone got any cleu?
Add a canvas component to each item and override the sorting. I think there's a way to code it, because you can make a bunch of layers with names, so presumably you can assign them that way, but I'd have to look into that.
How exactly do I do that? I didn't even realize you could add components to visual elements let alone how
bottom of the inspector panel, easiest to use the search bar, but you might find some interesting things if you take a look
All I see at the bottom of the inspector panel is transition animations
you need to use do it on the file and then just put those in a hierarchy if you need to, or you can adjust the Z-index if they're all in the same group
What do you mean "do it on the file"?
the uidocument
Oh you mean the game object. There really aren't any easier ways to do this using just a single visual tree asset?
public void PlaceBehind(UIElements.VisualElement sibling); public void PlaceInFront(UIElements.VisualElement sibling); public void SendToBack();
I guess I can try this, but by god do I not like that this is what I have to do
lol, yeah, I'm looking at 700 ui elements right now like....nahhhhh
I only have to do this with like 4 of them
I'm making an entire periodic table
With a custom UI shader graph, is it possible to get screen space UVs instead of "element space"? The object and world transforms seem to be identical, and I can't find any relevant UI node in shader graph.
where can I find good 3d models of space ships? Is for a space ship sci fi game
Does the Screen Position node not work?
𤦠wow, of course.. thanks
Forgive me but I can't really find any code example on UI Shaders, only got this https://www.youtube.com/watch?v=xAOBBW9hsjA and the docs, which does not have a shader example in https://docs.unity3d.com/Manual/UIE-examples.html
Because I haven't used UI toolkit much before, and I have straight up never used the Shader Graph before, how would I go around making an occlusion effect where a UI World element gets darkened by the World, but its still visible? Using Scene Depth and Scene Depth Difference nodes? Also stencil?
With Unity 6.3 LTS, you can now use custom shaders in UI Toolkit. Watch this video to learn about how to create dynamic, interactive UI effects using Shader Graph. Youāll get the steps for building a reactive, glowing button from scratch and learn how to drive shader parameters with C# for high-performance, responsive interfaces.
Whatās Cov...
I just cannot find anything regarding ZTests, Depth, Stencil, Multi pass rendering or occlusion effects
does anyone know how I would add a draggable separator to dynamically space these two visualelements in ui toolkit? (between pined and recently accessed)
Hello there. Let's say I have 10 ui Toolkit elements, using a custom shader. Now I wanna change a property of one of them. How do I achieve that with creating a new material for each visual element? Like Materialblocks?
Use a TwoPaneSplitView
-unity-material: url("blah") prop("_Tint" rgba(141, 214, 112, 0.4)) prop("_Example" 0);
Is it correct to say that the ui builder for ui toolkit doesn't include every piece of ui available(since I did not in fact see TwoPaneSplitView in it when I first built this)
No idea, I don't use the builder
Is there any way for me to know if the property actually changed?
var prop = new PropertyField(nodeProperty);
prop.RegisterValueChangeCallback(OnPropertyModified);
or disable any events that call this valueChangeCallback when it actually hasn't changed?
For example, it calls the callback on bind, which doesn't make sense since the property didn't change.
I know of TrackPropertyValue, but sadly the regular intervals where it checks it changes? sometimes its really often, sometimes its not
Actually, nevermind! I see what the issue I was having before with the regular intervals changing. When I use TrackPropertyValue, there's two ways it can get called from:
The way it's really frequent, done by
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
And the not so frequent:
UnityEditor.RetainedMode:UpdateSchedulers ()
It changes doing the same action, can trigger the track property event from those two diferent points. Usually it changes when I do Ctrl+Z.
I want always to use the GUIutility processevent since it's faster. Is there any way to force that?
actually I was going to say, does RegisterCallback<ChangeEvent<T>>(OnPropertyModified) work?
https://docs.unity3d.com/2022.3/Documentation/Manual/UIE-Change-Events.html
I do not know T, since it's a PropertyField and im drawing a default inspector (i don't know actually what type the properties are)
RELLEVANT NOTE: This is Editor code, a tool
maybe this isn't your preferred solution, but you might be able to let T be object if you do not care about the old and new value, and afaik this also works for Editor
It doesn't get called if I use object š
My focus is now this, somehow it changes when I do undo to the proper way, and TrackPropertyValue is perfect
If it was always called often
Managed to fix it, it seems calling Bind() inside a schedule.Execute triggers something weird, making the binding not work properly
Hi is there anyway tutorial for the use of SCROLL RECT, or SCROLL VIEW for a lobby list in a lobby system?
The main docs are pretty good. You'll just need to add you lobbies to the scroll view
https://docs.unity3d.com/6000.3/Documentation/Manual/UIE-uxml-element-ScrollView.html
So would it be hard coded then?
That would be easier
You can also bind it at runtime if you want.
Yes that what my plan is but because Iām implementing the lobby UI as a pop up from a main menu I had to use UITK legacy UI would be easier.
I want to center the "Ayarlar" text in the Top visual element while keeping the button aligned to the left. Roughly speaking, I made the "Ayarlar" text absolute, gave it 30% spacing from both the left and right, and centered the text within itself. However, Iām wondering if there is a more professional way to achieve this, or if this method is sufficient.
Also, should we make our template responsive to all screen sizes from this screen, or is it enough to adjust it from the Panel Settings section? Does the layout here not matter that much?
Not a place to advertize
Sorry found the section forgot to remove here
I'll be honest that i cannot understand how the UI Toolkit world space UI Input works. I have the required raycasters on the camera, the event system component, and the raycaster/event handler component on my UIDoc.
Even with these things, I have no clue how the event handler sends event data. It doesnt seem to do it with event callbacks that you would register with on an visual element. It also doesnt seem to provide any public ways of registering/ recieving events.
I looked at the Script for event handler; and all it does is call sendEvent(eventtype, pointerdata) (with no accessable base class). i have no way to see where these events go, as registering the event callbacks on a UI element on the worldspace UI have no effect.
I can create my own raycaster and event handler, and publish events for my ui manager script to use the events that are on screen, but that wont work for more advanced usecases, without creating a robust api that completely bypasses the event system (and not use the ui events you would normally use for UI Toolkit).
Could I please get some help on how your supposed to be able to get/respond to the events created/published by the panel raycaster and paneleventhandler object?
Do you have the panel input configuration set up?
https://docs.unity3d.com/6000.3/Documentation/Manual/ui-systems/world-space-panel-input-configuration.html
yes, ive set that up completely. what is supposed to happen with those components? when it sends a event, is it to the ui's event system? i just have no clue about the intended target, so i cant debug
i can bypass the components to create my own input processor, but how should i recieve the input/events from those components?
It uses the regular input and event systems
https://docs.unity3d.com/6000.3/Documentation/Manual/UIE-Runtime-Event-System.html
You'll need to switch to the Input System UI Input Module if you. Haven't already
I'm dumb, i see the documentation, sorry for the ping and thank you for the link. ill figure out whats wrong then. wish i found this when i was searching for info on the panel components
Alright, figured out the problem, abiet i have no clue how to fix the solution. if you disable the automatic input configuration when you have autoredirect on for the event system, you need to configure / add panel raycaster/panel event handler yourself. Thats completely fine.
However, unity doesnt ever explain how you are supposed to do it. based on the code, all i can do is just set the IPanel of the raycaster and event handler. Neither uIDocument.runtimepanel or uidocument.rootvisualelement.panel seem to initialize the components. both options set the panel asset to non-null and registers callbacks for the dispose event, but nothing else. these panels seem to recieve input, but they always get event data created by a physics raycaster, rather then a worlddocumentRaycaster (unless i disable the physics raycaster, then they dont recieve input at all)
Do i need to have the panel components under the event system when i create them? i cant seem to find any data about "How" to manually assign the components. (i want to manually assign some, because only a few worldspace ui actually wants to get events, and for the other ones, i dont want them to interact with the event system at all.)
(noted, spawning the gameobjects under the eventsystem on awake doesnt work, seems like i have to register it with the InputSystemUIModule somehow)
hey guys, im having this issue where i have a rescalable health bar but the health fill portion of it wont resize properly, the way i made it, they both change width the same way so im not sure what the issue is, I have them both as 'sliceable' sprites and they should have the exact same slice points (they also have the same dimensions and import settings
whatever is wrong, it just seems like i cannot win. i cannot edit the eventsystem class to debug why the worldDocumentRaycaster never gets priority over the physicsraycaster (even though it does give a correct raycast result when debugging its methods). the panel Raycaster never ever gets called, even with valid runtime panel assigned. the panel event system gets called, but its always passed a physicsraycast object (no doc), so it fails. Theres no documentation on how to register a panel raycaster/event handler, or how to add it to the RaycastManager class. Theres also no scripting code that you can read on how the InputSystemUIModule autoconfigs the worldspaceUI.
Second update, allowing the autoconfig of the panels ONLY allows input to the screen space panels, the other panels never get any input, and if you disable all the screen space ui, no ui gets raycasted against. I really dont know how they want us to do worldspace.
ah i figured it out, i had the image set to 'filled' since i was going to have it reduce, but now im wondering how i can have an image in both sliced and filled mode
has anyone figured this out (or some sort of workaround) yet? ive been messing around with masking for a while and getting nowhere with it, i really wish image sliced mode and filled mode werent mutually exclusive
Just shared a futuristic concept in #ui-ux, what do you guys think of using this style for mobile interfaces in Unity
Hello im making a billiards game and i would like to create a simple display of which balls are left to pot on the top. I have ball texture jpgs and i would like to make it so there are circles each with its own texture on the top how would i do that. Here is the image of my setup
THing is i want it to only take the center parto of the jpeg piicture and i want it to not be stretched like it is now
Utilize masking and background fill mode "scale and crop" (also known as envelope parent in ugui)
https://docs.unity3d.com/6000.3/Documentation/Manual/UIE-masking.html
https://docs.unity3d.com/6000.3/Documentation/Manual/UIB-styling-ui-backgrounds.html
thank you
Does anyone know how to bind sorting methods on click to headers of MultiColumnListView, version 2022.3, I couldn't find it on the unity documentation. I've tried the headerbinding and registering a click event to the header visualElement but found no success
Hello guys
Anyone knows why I'm having this difference
from game screen and preview screen?
game is all blur
seems SDF not working at all
But this is a SVG and SDF fonts they should scale at any resolution no?
When I zoom in the UI builder it's all crispy but when I zoom in game mode it's crappy
The game view is rendering at this resolution, you are zooming into that resolution
So when I build my game it will scale proper? To any resolution?
It scales to any resolution now, just increase the game view resolution
instead of the zoom
I see, will try it, thanks
One question, why text mesh pro works with zooming? And UIToolkit don't?
UITK does
Well, not using the game mode zoom, I understand that it should work on the resolution however TextMeshPro also works with any resolution and zoom
UIToolkit and Text Mesh Pro both use the same Text Core backend, if your text has problems at high resoutions when using either then the font asset hasn't been properly set up
It's only when zooming in game mode and only with toolkit, other than that it's all good
Bump
Does worldspace UI Toolkit support backface culling?
Whats the recommended way to add ui having multiple game objects with UIDocument or a single one and handle it adding the templates into a single UXML?
I cannot seem to find it anywhere at least. Custom UI shader graph shaders don't have a culling option either and also manual culling with Is Front Face is not possible with UI shaders. If I slap the default Unlit shader to a UI element, it does seem to cull though it obviously doesn't render the UI element properly. It still makes me think it might be possible with custom HLSL shader but the UI shader graph doesn't seem to be an option. I can try if the generated code from shader graph with the culling modified would work. Don't know why culling isn't supported so far so (the shader graph seems to be more so useful for overlay UI so that might be why) even if it worked, I don't know if that is solution that will work on different platform builds and stuff
@bronze iron Using the generated code from a UI shader graph and just turning on culling on the shader code seems to work in the editor at least so that might be pretty much the only way. Of course one option would also be to do a C# script culling where you disable the UI elements that are facing away from the camera
Doesn't really matter regardless. TMP might render crispier edges, don't know why. Using the game view zoom is not supposed to change anything regardless what method of rendering is used. Zooming in game view just makes the pixels on your screen larger. If by blurriness you mean the anti-aliased edges, that is a good thing if anything
If by blurriness you mean pixelated, I don't honestly believe TMP could make any difference, no method of rendering a font can introduce pixels where there aren't any
Thanks
so what is the actual proper way to hand off a data source chain to a custom visual element?
e.g. i have this struct "RangedSpawnParameter". it has an enum "mode", a min and max float value. but when i set the data source path to my custom element to point to this property on the parent it doesn't seem to pass it down automatically to the custom element. what does it take to accomplish this? (i am not using the serialized object/binding system, i'm using the data source approach). i can't seem to find a good resource on how to do this the cleanest and easiest way. anyone know?
img #1: this is the custom element, and the data source path points to the expected property on the parent data source
img #2: The scriptable object that is the data source of the parent editor ("rate" is what we're focusing on)
img #3: the custom element (UxmlBoundElement is my own abstract that just handles all the binding to the UXML doc).
i need to figure out how to have the data source pipeline give me a way to access the parameter internally. i've been beating my head against walls trying to find a solid resource on this specifically.
Anyone know how to tint a svg when hovering it using uss ?
Tried this:
.icon-image:hover {
-unity-background-image-tint-color: rgb(255, 0, 0);
}
Doesnt work
Does anyone else's style sheets not enforce some properties correctly sometimes (i.e. button radius and border widths among other things, sometimes even width percentages) and only works when you set styles inline? They reflect on the actual components when you add the style, but when I go to actually display the UI it does not display
I can't even edit hover background color from ui toolkit, this is so
Isnt it supposed to work?
You should use the UIToolkit Debugger to find out what the specificity of the style you need to override is.
You need :enabled:hover
It's probably also a specificity problem. Use the UIToolkit debugger and look
Where should I look? I opened it and what exactly should I look for to identify this?
expand the Matching Selectors
where?
Why do we have the Image component if we can use a VisualElement and in the Background set an image to it?
I couldn't change the tint-color for the image when hovering but I can for the VisualElement so I had to use it
I don't know, I don't use the Image component
What you usually use? Visual Element?
Yes
Ok, so I'm on the right path, thanks
Hi all, I am working with UI Toolkit data bindings for the first time. Why is it that the ListView displays 'List is empty' when I manually reload the contents of the Scriptable Object list?
Calls for opening and closing the pop-up with the list view
/// <summary>
/// Opens a file, updates the beatmap from the selected file, and refreshes the editor.
/// </summary>
private void HandleOpenClicked()
{
UpdateBeatmapListSO();
m_BmPop_ListView.Rebuild();
m_BeatmapPopup.style.display = DisplayStyle.Flex;
}
/// <summary>
/// Opens the file from the selected popup entry.
/// </summary>
private void HandlePopupOpenClicked(System.Object item = null)
{
var active = item == null ? m_BmPop_ListView.selectedItem as string : item as string;
if (active != null)
{
UpdateBeatmapFromFile(active);
ClearMap();
UpdateEditor();
HandlePopupCloseClicked();
}
}
/// <summary>
/// Closes popup view and returns to the main editor interface.
/// </summary>
private void HandlePopupCloseClicked()
{
m_BeatmapPopup.style.display = DisplayStyle.None;
}
Call to reload the contents
private void UpdateBeatmapListSO()
{
m_BeatmapListSO.Beatmaps.Clear();
m_BeatmapListSO.Paths.Clear();
var res = GetBeatmapList();
m_BeatmapListSO.Beatmaps = res.Item1;
m_BeatmapListSO.Paths = res.Item2;
}
Before the refresh
After the refresh
Checking my SO and through the locals in the VS debugger, the data is still present in the list, successfully deserialised from the refresh. Just that the binding doesnt see it anymore.
I found the fix.
I must re-assign the itemsSource
m_BmPop_ListView.itemsSource = m_BeatmapListSO.Paths;
Iām currently trying to use Unity UI Toolkit. Iām still a beginner, but I want to do things in the most correct way and learn best practices.
At this stage, could you first help me understand how to solve this problem?
I have a "top" visual element, and I want to place a scroll view right below it. However, I had to set the top visual element to absolute because when it is in relative mode, it covers the entire screen (as shown in the second image), and it creates a strange layout. When I try to change its size, it still occupies the whole screen.
When I switch it to absolute and give it a height of around 5%, it looks correct (as in the first image), and the scroll view starts from below it as I want. However, in this case, the scroll view overlaps the top element (as shown in the third image).
If I set the top value to 5%, then it works visually, but Iām not sure if this is a correct or professional approach. I feel like there should be a better and more proper solution.
What would be the best practice for handling this situation?
How do I draw the defaul inspector for KeyCombination? Would I use a propertyField?
To be clear I want to embed the default property drawer for KeyCombination class in another custom UI Document
You probably want relative with no position overrides, and flex grow 0 (which is the default not overridden iirc)
The scroll view would need to be flex grow 1 to fill the remaining space
Yes, that worked. Thank you!
When I add a VisualElement inside a ScrollView and set its width to auto, the background color does not appear. However, if I give it a fixed pixel width, the background color becomes visible.
How can I solve this problem? I want this element to take up 100% width, but in that case the background color is not visible.
I think this is happening because the parent does not have a defined size, but I cannot directly modify the unity-content-container. So how can I handle this?
I figured it out ā it was happening because I set overflow to hidden. However, I actually want to keep overflow as hidden because I donāt want the content that extends beyond the bottom of the main screen to be visible. How can I handle this?
You need a mask
This is a layout issue, and is not likely related to overflow even though it has some effect when Align Items is not set to stretch. You probably set Align Self on the parent scroll to flex-start which causes the scroll view container's width to be intrinsically 0. Either set it back to AUTO or use stretch
If you're stuck again in the future, right click bold changed fields and click Unset to debug from a clean slate
thank you š
Hello, who can help me))
I cant find sort order, why? (World space UI toolkit).
I'm having a problem and can't get the 9-slice to work properly. Any ideas?
Check debug panel
But I checked it before writing, maybe I missed something)
Sorry I meant the debug inspector
Thanks)
But it didn't help, even if his sort order is higher, the sprite is drawn on top, even with a lower layer, 2D game.
I used Sorting group before but its a terrible solution
Well, what does that mean? Unity's latest thing is just for fun. I'll have to do it the old way with sprites, at least I know how to render and batch things.
i think this image might be legacy UI from the screen space settings, it doesn't really make sense for world space, how can a world space UI document have a sort order, why not use the world space axis?
I used sprites, but for example, I would like to make menu buttons above items using the new UI... add sorting groups will help there, there won't be many of them, so it will do.
But yes, everything is "as usual" with Unity.
Does any one know if the UI Toolkit has any known issues with touch screens? Im having some odd behaviours...
Yes there seem to be some issues, but nobody has ever specified what they are.
Does UITK not support gaps for flex items with a single property?
How do I add a property selector for KeyCode, or any other type in ui toolkit? Is it through the propertyField?
If so, how do you do it? I'm finding the documentation surrounding propertyField to be very confusing, and I have no idea if I should be using Binding for it
Hey y'all does anyone know how to apply a shader graph material to only the background of a button? This is what it looks like when I just straight up apply the material to the button:
Looks like the label gets obscured too
If anyone has the same problem use the Render Type Branch node, just learning this now.
You need to add that. If your colors are messed up use a colorspace conversion from linear to RGB.
Hello! Is there something like a canvas group that would allow everyone to set the picking mod = ignore ? Going foreach all the elements that are no longer needed isn't a very good solution.
How can I replicate default drawer behavior?
public abstract class WithRarityDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty newProp)
{
if (Settings.CustomInspectorsEnabled == false)
return ();
}
if this bool is enabled I just want default behaviour like there is no custom drawer but calling base leaves me with the "No GUI Implemented" result
If vertx is reading this I did try looking at the unity huh how website but I don't think your page for "No GUI Implemented" covers this
Return a PropertyField using the property
I can turn the bat signal off now š
I think i'm still getting no gui, do i need to bind it or anything else?
public override VisualElement CreatePropertyGUI(SerializedProperty newProp)
{
if (Settings.CustomInspectorsEnabled == false)
{
PropertyField defaultField = new PropertyField(newProp);
return (defaultField);
}
Are you sure that code is running?
Oh hm, good shout I made a bad assumption. It's not but I don't know what to do in this situation because i assumed that either
A. it's not running therefore I get default behaviour
B. it is running and im explicitly returning default behaviour
Settings.CustomInspectorEnabled is being set via a MenuItem, I just want a nice global way to turn all my custom stuff off. Is there a better way to do this?
oh maybe it's because it's being drawn in an inspector where I'm doing this and it's a similar issue?
[CustomEditor(typeof(SelectableLevel))]
public class SelectableLevelEditor : Editor
{
public override VisualElement CreateInspectorGUI()
{
if (!Settings.CustomInspectorsEnabled)
return (base.CreateInspectorGUI());
}
}
ah i think i found a forum thread confirming this
yup, as per https://discussions.unity.com/t/drawdefaultinspector-support-for-ui-toolkit-empty-createinspectorgui-in-editor-class/1503477/6
I needed to do
public override VisualElement CreateInspectorGUI()
{
if (Settings.CustomInspectorsEnabled == false)
{
VisualElement root = new VisualElement();
InspectorElement.FillDefaultInspector(root, serializedObject, this);
return (root);
}
}
ty for the help, showing how to do default drawing on both of these might be a cool thing to add to your very helpful website š
Is there a particular reason the panel's focus controller doesnt have a FocusChanged event or delegate? It seems like something that would be really useful, especially because the focus events dont always fire
how to change line spacing in label becuse it is not found in UI Builder
It seems rich text and font assets are the main two ways: https://discussions.unity.com/t/how-to-change-line-spacing-in-ui-toolkit-for-label-element/920434
thanks
what about this what is the best way to remove those spaces instead of resizing the icon
Hey I'm trying to put this to text on an image for a button prefab but I can't put them on top of each other?
Image
Hey, really dumb question but I want to kinda confirm and hear from someone that has more experience, I've created a bunch of UI with UI Toolkit by now and I've come to the realization that most of the time I really really really only have one single gameobject with the PanelRenderer component. Is it OK and realistic to just kinda create the entirety of the UI through code? Given that it only requires the UXML being assigned
Because it really seems a sensible thing to do, unlike with ugui
Nothing wrong with that. It's all personal preference. Some folks have never touched the UI Builder
Yeah you can do that. I have houndred thousand lines of code doing that never touched the ui builder. Its basicly building a website with the .uss and visual element
Hi there. I'm trying to understand how this (see attached 1) works : i put a binding by type of my c# class (plain class, system.serializable, that's it)
From what i understand, i selected a type of object i can put in my datasource, in my object, and then i can, at runtime, put an instance of my class as the datasource via script.
However, i'm getting spammed with warnings (see attached 2) that my datasource is empty and that unity can't bind it ? This is making me think that i cannot do it that way, or that i'm misconcepting how it works. Anyone might guiding me to ressources on this topic specifically? I sadly did not find anything on the docs for that.
Then, as a test, i did add a contextmenu to my start function to be able to execute it out of play mode, and the warnings stop. Though when i open my UIBuilder back up they come back and my datasource is set at empty. I supposed we're not supposed to do this out of playmode.
(please ping me whenever u answer to my message dw bout me :) )
On another note, the bigger problem for me seems to be that my world space text isn't showing and i have no idea why. Is it bc i'm in HDRP? Here's what the debugger is telling me :
Here's my uibuilder preview
Here's the uxml code
<ui:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement style="flex-grow: 1; background-color: rgba(106, 106, 106, 0.81); height: auto;">
<ui:Label name="Title" text="Title" style="-unity-font-style: bold; font-size: 48px; -unity-text-align: upper-center; -unity-text-auto-size: none; flex-grow: 0;">
<Bindings>
<ui:DataBinding property="text" data-source-path="LocDisplayText" data-source-type="App.Localization.DisplayableLocalizedString, Assembly-CSharp" binding-mode="ToTarget"/>
</Bindings>
</ui:Label>
<ui:Label text="Desc" name="Desc" style="-unity-text-align: upper-center; font-size: 31px; height: auto;">
<Bindings>
<ui:DataBinding property="text" data-source-path="LocDisplayText" data-source-type="App.Localization.DisplayableLocalizedString, Assembly-CSharp" binding-mode="ToTarget"/>
</Bindings>
</ui:Label>
</ui:VisualElement>
</ui:UXML>
I'm a bit confused with ui toolkit around how we are meant to make custom components (like you would int he web world with vue/react etc) . The info online seems to indicate we should inherit from Visual Element and in the constructor do Resource.Load the uxml file then clone the tree into itself which seems really odd and I thought unity was trying to move away from Resource.Load.
Is there a better way to represent a components logic, styling and uxml without doing this? I want to keep things self contained, reusable and consistent ideally
does anyone knows how to put animated sprite in ui toolkit? afaik theres no built in way
Animate it through code or a shader, also had to do that in ugui iirc
private void OnEnable()
{
inputReader.onPlayerMenuTogglePerformed += ToggleMenu;
var root = playerMenuUI.GetComponent<UIDocument>().rootVisualElement;
Debug.Log($"Root found: {root != null}");
var scrollView = root.Q<ScrollView>("SlotScrollView");
Debug.Log($"ScrollView found: {scrollView != null}");
if (scrollView != null)
{
for (int i = 0; i < slotCount; i++)
{
var slot = new VisualElement();
slot.name = $"Slot{i}";
slot.AddToClassList("Slot");
slot.style.width = 40;
slot.style.height = 40;
slot.style.backgroundColor = Color.red;
slot.style.flexShrink = 0;
slot.style.flexGrow = 0;
scrollView.contentContainer.Add(slot);
}
Debug.Log($"Slot count after add: {scrollView.contentContainer.name}");
}
}
is this the correct way to add VisualElement at runtime?
Can just do scrollView.Add
Is it possible to add effects? I'd like to add an outline highlight effect to a visual element when it is displayed
do you mean while hovering or just make outline color change?
I mean like an outline around the element which appears and then fades out
you can try transition animation and use border color as the property
just fade out color alpha
I haven't used SVGs yet, but is there a list anywhere of what they do support? ex. coloring, shaders, etc.
What version of Unity are you using?
You seem to have anti-aliasing (AA) on the SVG so you must be on 6.3 or newer where AA support was added. I have tried it on 6.3 and the anti aliasing looked horrible. I ended up rasterizing all the SVGs into high quality textures and enabling mipmaps which looked wayyyy better than the SVG stuff. Luckily those vector image sites usually offer tools to choose colors and export high quality PNGs.
SVGs were useless without AA but even now they have been totally unusable with the poor rasterization engine. Anyone let me know if the quality of SVG rendering has improved since 6.3, I haven't seen that talked anywhere at least. If you find solution to this, I'm very interested, maybe there is some setting somewhere that I'm not aware of.
Surprisingly the "proper" SVG support in 6.3 has been talked very little about from what I can see. Not enough to even find any reference images to compare against. If it worked well, SVGs would have a potential to become a default way to display UI icons. In the current state (in 6.3 at least) I don't see any upside to using them
I'm on 6.3 and mine look fine
Default is fine, imported as Antialiased Arc Encoding
Especially small images look very bad. Even with larger scale some parts of the edges look much too sharp to my liking, a texture based one looks simply nicer
I should add that this was using the same AA Arc Encoding, the AA is clearly enabled but just doesnāt do very good job
Wait why did you remove everything?
is anyone aware of some settings that could cause UI to just never display and be considered 0 height on HDRP?
Project wise, uxml wise...
Cause atp i have tried creating a simple fullscreen uielement and it just doesn't show.
unity 6.3.10f1
Iām having an issue with the vertical scrollbar. I can change its color using the :hover pseudo-class, but not with :active or :focus while Iām dragging it.
If anyone knows how to fix this or can point me to the relevant documentation, please let me know.
you mean you are losing hover stying? if so you can combine them like this selector:hover:active:focus
I will try
Hellos i was wondering if the Dragon Crasher sample is still the best one sample to gain the best knowledge on how to make a good UI toolkit structure both that work vertically and horizontally?
When using world space UI for player nameplates, do you need one panel (or panel settings) per nameplate?
It would be one UI Document per nameplate. they can all use the same panel settings if you want
Any good resources on using gamepad with UI toolkit?
I had to resort to so many hacks/workarounds that i dont think im doing it right
The hover/focus property works poorly so i had to manually listen to navigation events and add/remove custom classes
Sounds like you want to use a virtual mouse cursor
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.19/manual/UISupport.html#virtual-mouse-cursor-control
No, i want to navigate using the gamepad by selecting buttons just like it happens by using the focus property, however if i use the focus property then whenever i click with the mouse it stays focused forever even after clicking it
I want to be able to show the user the selected button (by changing a color or size or something) but only on gamepad, if i use focus it has this problem when using a mouse
Kinda stuck right now with implementing a ListView that can bind to a typed collection from the parents binding.
I've looked at several forum posts, read the guide provided here https://docs.unity3d.com/6000.3/Documentation/Manual/UIE-runtime-binding-list-view.html and yet, it still does not work.
The farthest I've gotten is the list will render the appropriate amount of Visual Tree Asset templates assigned to the LIstView template attribute, but the bindItem itself seems to not be working, as the templates are not recieving the binding data...
Almost all these examples online show using Object binding, with ScriptableObjects, I'm trying to use TYPED binding...
I'm honestly just trying to find the idiomatic way of doing runtime Typed binding with UXML ListView... like, this shouldn't be so hard, yet, its just not working as one would expect...
Welp... figured it out, I was using ObservableCollection, switching to List fixed everything
Amazing stuff guys
is there any way to have curved text?
I don't think the default text component can be curved by itself. Would a texture of curved text be an option or do you need it more dynamic? One option that I could consider is to render the text to a RenderTexture and then put that on a curved surface (curved mesh, could be curved via vertex shader)
its a text field specifically and the image behind it is curved thats why i wanna curve it
What I was asking is whether you could curve the text outside Unity in image manipulation software for example and put it in Unity as a texture? That would be the easy solution. Even combine with the image behind to match the curvature
But the text changes its an input field
I thought of the other way u suggested but dunno if its gonna be reliable
Or even worth it tbh
Yeah sure, then a premade texture is obviously not an option. Unity does not support curved texts I don't think so you would have to do it yourself. I agree the RenderTexture option can be quite bit of work to get working but that's the easiest solution I could think of. Shaders would be something potentially worth experimenting with too but I'm not too confident it would even work since the UI Shader Graph doesn't support vertex manipulation and therefore it could be a huge problem trying to add extra padding around the text to fit the curved one (adding actual padding could work though I don't know whether it actually scales the mesh rendering the text)
Yeah no I doubt the UI Shader Graph will be much of help
custom HLSL shader perhaps (probably vertex manipulation allowed too)
ok ill try some things and update, maybe others need it to in the future
I just created a TextField and it's clearing when I press escape. Is this default behaviour or is something wacky going on?
(sorry if this is the wrong place to ask, not sure why it's under "artist tools")
Hello everyone!
I have an issue with a transition i'd appreciate some help with.
See i have an element with a set size (h and w) and a transition all. I add a class to this element when clicked that applies a different size, however the animation is not taking effect. I added a color change for debugging purposes.
This is a component so I'll add the element C# class here, know that the USS class is applied because i can see the color and size change, just not the transition
Materials:
UXML and USS -> https://pastebin.com/qAR0K3bE
C# Element -> https://pastebin.com/kP62iCe5
Expected:
Size and color change and animate
Result:
Size and color chanes (class aplied correctly) but it does NOT animate.
Thoughts:
Maybe the re-parenting affects this? If so is this expected or a bug?
Please ping if you need any more info.
Hey so, Re-parenting is the cause of the issue! I can fix my problem but the question still stands:
Reparenting breaking animation is an expected behaviour or a bug?
Hey quick question. Are custom controls usually implemented in other templates via template or just directly?
Example: I have a CustomControlThingy.cs. Should I put those in a .uxml to implement the control somewhere else or should I just use the custom control directly (but then it lacks any styling afaik)
Custom controls can definitely be used to modularize existing uxml files, it depends on what you're doing
Hello,
in my game I have horizontal scrollview, which contains buttons. Scrollview is filled via itemTemplate.CloneTree() function in script. When player click on some button I want to clear existing buttons and give it new offer - so I am cleaning scrollview via *.Clear() function. and adding new buttons via Add() function.
My problem is, that after addding new content to scrollview it is randomly scrolling to one side. I tried to use:
sc_Selection.schedule.Execute(() =>
{
sc_Selection.horizontalScroller.value = 0;
sc_Selection.scrollOffset = Vector2.zero;
}).ExecuteLater(0);
or geometrychange event, display.none. But nothing solved this randomly scroll :/
How would you make the scrollview start on first element without scroll animation after loading new content? Thank you! ā¤ļø
Anyone know how I force a refresh in the ui builder? it happened multiple times now that it doesn't recognize a chnage and I can press ctrl+r as much as i want. (Hot Reload off/on tried already).
well i guess i can just change another value to tell unity again smth changed
is there a way to bind class property to material property in UI builder?
like ... is there way to bind only certain material props(float, vector4, etc)? or do I have to bind the whole style.unityMaterial thing
Why my runtime PointerDownLinkTagEvent always return evt.linkText as "test"
UI Builder keeps crashing for some reason š
<!-- <Bindings>
<ui:DataBinding property="enabledSelf" data-source-path="Display" binding-mode="ToTarget"/>
</Bindings> -->
so this is crashing unity for some reason...
Okay I had to split visual elements and pass in classes from there. Weird thing is it worked fine. It only blows up when I made change in UI builder
I think this is the right channel. I came from roblox studio, and one of the things that hit me like a truck was the fact there's no uicorner and other built in tools in unity. Are there any plugins that expand the gui component/option segments for this
What exactly are you looking to do? I'm not familiar with roblox
Round the edges of corners in gui
You can do that through style sheets with Border Radius
it's in border
nevermind VisualElement.Querry<PropertyField>().Where(p => p.bindingPath == "_name").First();
I'd like to ask some general questions about UI toolkit.
I am building software for machine simulation, something like Powermill but more specialized. I started it on C# WPF with thirdparty library for collision detection, but I am hitting limits and thinking about moving to Unity
I do know something about MVVM and bindings, but in WPF
Does UI Toolkit use MVVM too?
Does it rely on Microsoft.CommunityToolkit.Mvvm package and INotifyPropertyChanged or it runs on its own library for bindings?
You'll want to check out the App UI package
https://docs.unity3d.com/Packages/com.unity.dt.app-ui@2.2/manual/mvvm-sample.html
Guys, What in button's properties in ui builder that changed when the button is clicked ? I want something that bindable
Like value of slider , it change when the slider is adjusted, and it is bindable
I want somethings similar in button, anything, i just want to get the the signal
Nice example, but does UI Toolkit really require dependency injection?
base.OnConfiguringApp(builder);
// Register pages as Transient services
builder.services.AddTransient<MainPage>();
builder.services.AddTransient<AnotherPage>();
builder.services.AddTransient<SettingsPage>();
// Register ViewModels
builder.services.AddTransient<MainViewModel>();
builder.services.AddTransient<AnotherViewModel>();
// Register other services
builder.services.AddSingleton<IMyService, MyService>();
I did not really use this and it feels overengineering
ListView i need the vertical scroll bar to be on the left of the container not on the right. HOW? google doesnt know.
@graceful carbon is there an alternative in AppUI?
Not for list view. I think you should be able to move the position of the scroller under the scrollview. It might be easier with a uss selector
if you know by anychange which uss selector i see a bunch of them.
probably any one of these or you can add your own.
changing the flex on the container of the scroller might work too
you cant find it from ui builder
selectors are kinda complex
use ui debugger
matching selectors on the right side
does vector/svg in UI toolkit get rasterized when imported/used?
No
I would recommend testing whether the SVG images looks any good for you though. I myself have found the anti-aliasing being very lacking making SVGs in general completely useless since high resolution texture just looks much nicer
yeah š now I'm noticing it
is there a way to change individual shape colors in unity/ui toolkit vector/SVG on runtime?
is it possible in UI toolkit .uss classes to define a set of properties in a var / function, and then when you create styling for a selector, you just say the variable name to apply those properties., eg:
var specificStyles {
width: 80%
height: 80%
}
.class-selector {
using specificStyles
}
No
Not without a third party package like the few that let you write SASS
is that more of me wanting to use uss in the wrong way, or just hasnt been looked at for UItookit yet?
Anyone know if there is a maintained plugin that combines uxml, uss and a cs file similar to Vue Single-File Components?
Hi all , can anyone tell me what is problem ???? my screen : 1280 by 720 but even I reach the edge it say 802
Debug.Log($"H: {Screen.height} , W: {Screen.width} , POS:{new Vector2(evt.position.x , Screen.height-evt.position.y)}");
check anchor?
what ?
Is your game view scaled perhaps?
anchor of the visual element. sorry, I meant transform origin
maybe the origin is on the left/right edge of the element?
that is screen but even I select free aspect I get same problem
oh got it but I use UI-Toolkit
I never touch that
also go to Window -> UI Toolkit -> Debugger and then click on Show Layout. maybe that will help a bit
Thanks
npp
Fixed from change from Constand Psychical Size to Constand Pixel Size from panel setting:
Been trying to figure this out for most of today, the UI in my Scene View is pretty crisp and looks good; but in Game View it looks very deprecated, specifically at 1920x1080 resolution - on my normal monitor which is 3860 x 2160 it looks great.
Any suggestions? The Canvas Scaler is set to 1920x1080 on the UI Canvas, I don't really understand why it is happening at the default canvas size
easiest way to show is in images, first image is in build at 4k, second is in build at 1920x1080, third is game view at 1920x1080 and fourth is scene view at 1920x1080
not sure if it's related but SVG mask tends to do that in my case:
I'm not using SVG's I imported the UI at a much larger scale than it is in order for it to appear as close to vector images as possible
then idk sorry x,x
It's all good!
Anyone know how to set up global variables in one uss file so its available in any other? I set a variable in the GlobalArcadeGames.uss file on the :root, but I can't access it in the ScreenUI.uss
Okay you can actually, but only directly in the .uss file. Unity will tell you it can't resolve it even tho it can.
I don't think aliasing is SVG issue... I created a shader that masks in hex shape and it's kinda doing the same thing too š
You have to handle anti-aliasing yourself in the shader. There is no automatic AA happening. SVG shader has AA but it just is bad
aww
Hopefully smoothstep or fwidth can help?
https://www.ronja-tutorials.com/post/046-fwidth/
The partial derivative functions ddx, ddy and fwidth are some of the least used hlsl functions and they look quite confusing at first, but I like them a lot and I think they have some straightforward useful use cases so I hope I can explain them to you. Since Iām explaining straightforward functions you donāt have to know a lot of shader pro...
Hey , does anyone know how to solve that issue ????
this part should find center of the button I don't know why it not work for me
use transform translate instead so it preserves the position?
just do something like:
if it's focused then translate to the right by 4 px or something?
Thanks it work
but still want to undersnad what is wrong with the code do you have any idea why I get that weird problem ?
this in an update loop right?
my guess is that it keeps drifting and updating since you use resolvedstyle? but just a guess
Thanks
HI, I'm new here. Where can I find the salon to ask anithing related to Unity problem's ?
about one of my project
#š»āunity-talk would be a good starting point
is it a good or bad idea to put everything in one UI document?
that is depend on your UI complexity
Hi guys does anyone why the scripts "On-Screen Stick" and "On-Screen Button" blocking touch inputs on android?
ugui and uitk have input checked together so this is expected
hmmm, i made a script to to fix it and now it works š
benefits of separate UI documents: you can reuse them. you don't accidentally change something in a different part of the UI. changes in the version control are easier to follow.
drawbacks: working with many different UI documents is tedious. especially if they are not cleanly separated.
I separated things into template anyway s:
Does anyone know if there is a way to return to the last opened UI Builder Instance?
Its pain to open a template and you cant go back maybe im missing smth
Tabs would be the dream here
ohhh found the 'open instance in context' THIS HELPS SO MUCH
Anyone else really enjoying all the QOL stuff being worked on for the inspector when working with Visual Elements. Glad to be able to filter out data I don't want to focus on and be able to see only the css values I want to look at currently.
Does anyone know who to stop highlight text when typing in the unsigned integer field?
which version is this?
is that in hierarchy directly?
looks great tbh, current debugger sucks
Which feature you wondering about.
The new Hiearchy or the search filter options.
They were introduced in two diferent versions.
I am on 6.3 I think they both dont exist
Oh you have a setting you flip on to activate it
Unity 6.3 was when the new hiearchy was introduced.
The search filter for attributes was introduced in 6.5.
note to reference visual elements into inspector fields you need 6.5 as well.
oh thanks, where do they introduce this though... Seems pretty important and I missed it even though I am using uitk a lot
For the where part
Project settings -> UI Toolkit category -> Enable Hiearchy Integration option.
I meant like where do they announce these new features, if they do it at all
thanks again for showing
where did you find these out?
They do posts on the Unity Forums about them.
Currently they are showcasing the new Panel Render which enables Animation support for UI Toolkit.
Not sure if this is possible, but what about going to a similar route of the Physics Core 2D module PhysicsEvent with the interface. Example the IContactCallback can just be implemented on non-monobehaviors. I literally just use it on pure C# object such as structs and classes that inherit from nothing. Just make a IUIReloadedCallback and have ...
Do note for finding them out I test the alphas and betas so I get a lot of hands on expierence with new stuff early.
I am currently making a set of videos for UI Toolkit new features for Unity 6.4, 6.5 and 6.6.
Note 6.6 is still alpha and major new features are still being add.
thanks! nice read, I dont understand how it enables animation support though
So the new Panel Renderer has some binding done behind the scenes. This allows binding ui properties to animation related stuff like in the animation window.
It also inherits from the base class for all Renderers which make custom shaders and a lot more other graphics related features start to be possible with it.
Oh I see, sounds nice. I have a uitk focused tool, seems like most of the stuff will get outdated soon. I try to close the gap vs ugui with custom solutions. For example made a transition animation tool for simple effects, it uses uss transitions but it is only for combining basic effects like scales, opacity etc
For shaders, I made some experiments, have a long message where I summarize them, it is long so will send in thread
Due note Unity 6.4 and 6.5 added a lot more support for Shader related stuff./
With the Panel Renderer introduced in Unity 6.5 inheriting from the base renderer class it now has support and access to a lot of SRP features.
I added some fancy stuff but my main goal was css gradients and shadows
Culling, shader data like screen position, SRP batching, and a lot more.
Well the most recent patch for Unity 6.5 added support for animating gradients.
animating? when did we get gradients lol
I go into more detail in thread but I have to find a workaround to shaders as I couldnt optimize them and cant do batching as far as I know(uitk filters)
seems like tons of updates are coming though, nice to hear
Yeah, that was one of the issues Panel Renderer fixes now.
Also ATG supports even adding a gradient tag as well
The gradients even work with shadows and outline on font.
these are great but leaves me in weird situation š uitk updates are so slow so I create custom solutions, they will become obsolote later but I also need them for my game
Oh sorry they aded animation support for the background position and repeat, but not the background gradient.
my bad, but there is a gradient tag for ATG for UI font stuff and there is a way for gradients on the background property.
Yeah, they had a slow progress because they kept support for the old UXMLTraits.
They decided to remove, (thank god), and focus on the UXML Attributes allowing for way faster dev speed.
Also half the engine moved their windows and editor to UI Toolkit recently.
They had to help with that which slowed down progress a lot as well, but not anymore.
- Rendering Debugger Editor and Runtime UI to use UI Toolkit.
- Animation Editors use it now and Timeline 6.6 and Animation Rigging 6.6 came out officially.
these sounds dope thanks for all the info again, it puts me in weird position as I also have this tool on assetstore but my solutions are like best case scenario for 6.3 lts so I guess thats fine, I will update & replace with official solutions as they come
One more question, Is there anything for playing particles on UI? Because even ugui doesnt have official solution for this right? everyone uses the package on github
Sorry I keep mentioning the Panel Renderer, it just happens to be the answer to your questions.
First there were a couple things Unity had to finish first before implementing that.
- The new VFX Graph Compiler update needs to be completed. This introduces new API for GPU Event support.
This was actually merged yesterday for 6.6. - Unity now has to implement the last set of SRP stuff for the UI Toolkit which they already started doing.
So with the Panel Render inheriting from the base Render class it opens up a lot of new SRP related stuff.
This was a requirement for particle support in UI Elements. I am not sure if they have a plan for them in Unity 6.6 or 6.7 yet
For those curious what I mean by new VFX Compiler with GPU Event support.
There is a commit for the upcoming changes to the new VFX Graph Compiler.
https://github.com/Unity-Technologies/Graphics/pull/8298/commits
Edit: I hate Discord for embeeding the GitHub preview.
.....oh Discord embeds the face of the GitHub user that created the merge request....sorry roland
Thanks again, learned lots š are you an unity developer? you are following everything with detail
Sorry had to think what I was allowed to say for a second lol.
I am not an employee for Unity, but just someone that helped find a lot of bugs in the engine and tracked them down. Also Unity has feedback sessions where they meet with devs and studios for asking about new features, current feature states, and more. I was part of the UI Toolkit one when Unity 6.2 was in beta.
Right now I am giving feedback for Unity 2D features. Tilemap, Physics Core 2D module, 2D renderer related things.
Unity gives credit to users on their website for helping with alpha and beta testing.
I am on the 6.4 and 6.5 credit list.
https://discussions.unity.com/t/unity-6-4-alpha-beta-special-credits/1718319
š Hey everyone, Unity 6.4 was released in March, and although weāre a little late to the party, we still want to take a moment to thank everyone who used Unity 6.4 during the alpha or beta phase and shared feedback with us. Weād also like to extend a special thank you to the following users who submitted bug reports during this time and ...
If you have any questions about the UI Toolkit, anything 2D related, or certain SRP stuff I might be able to help or point to someone who can help.
Or new features not shown on the forums yet, but in alphas/betas like 6.6 and 6.5.
I really want to use the experimetal animation ... but I'm scared to include it in my project lol
Honestly I would wait for a couple more 6.6 alphas. The next couple alphas will be adding more QOL and very nice features that helps UI Toolkit sers out.
we will just be able to install a new version right? my project uses 6.3
š is there a fix for UI builder crashing?
What version of Unity are you using?
sometimes making change/binding using UI Builder will break UXML structure that I have to fix manually
6.3
What patch of 6.3 are you on?
Also there were issues with editing the uxml file in the builder while having an ide have that file open in the past.
Also do you have the ATG settings turned on. There are known crashes with certain labels being renderer with ATG after a mouse hovers over them.
Going to be honest on 6.5 and 6.6 I haven't had a crash yet related to the UI Toolkit with the most recent last two patches for both.
Oh wait found a couple open reports of corrupted files when selecting objects for data bindings in the UI Builder in Unity 6.3 that is being investigated right now.
yeah this. mouse hovers over it, then it highlights the whole thing, then it crashes
what's ATG?
There are multiple bugs like you described being worked on right now.
One of the open reports could be what you are running into.
Link to the public bug reports of just a couple. There are a few more related to data binding and the UI builder other than these two.
Steps to reproduce: Create a new Unity project using the Universal 3D template Create a new UI Document (Assets > Create > UI ...
Steps to reproduce: Create a new project using Universal 3D template Go to Edit > Preferences > Search and change the "Object ...
Advance text generation - option in the project settings.
ah
it crashed before I had it ATG on
š I even has a counter on my stream as a joke
Depending on what you are doing turning it on might also fix your problem.
hm.. I turned it on recently. but I haven't run into anything much. but then again I haven't worked on UI for a couple days
I'll keep an eye on it and test around then. thank you
Not sure if you have the crash log text file but if you have the line it crashes on that could help.
But yeah, Unity had done a lot of reworking the UI Toolkit stuff starting from 6.4 and newer so things are easier to fix in them than Unity 6.3
š¤ I wonder how hard it's going to be to migrate 6.3 LTS to... 6.4?
is that the one with better version support?
So it depends on your project actually Unity 6.4 and 6.5 started removing legacy features making less bloat in the editor.
Usually the LTS is the best option which current one is 6.3.
Depending on the project going forward from Unity 6.3 to 6.4 or 6.5 should be easy and quick unless you are using one of the legacy features being deprecated.
Warning Unity 6.5 is still a beta. So version control your project before updating if you decide to test stuff out.
Mainly for UI Toolkit though the Unity 6.5 version is the one with the most changes.
It introduced the panel renderer.
what's the legacy feature being removed?
Unity is removing quite a bit of really old stuff. Don't use the UXML Traits basically.
Unity 6.4 deprecated them and fully removes them in 6.6.
So use the attributes like UXMLElement instead.
For other stuff out of UI they completely removed the old Render Graph compatibility mode now.
I would also avoid the old legacy input if you plan to update.
normally I created UIElements from UI Toolkit and I'm not sure if I use UXML Traits before
Reason for the old legacy Input they officially removed the UI Toolkit set input backend method and UIToolkitInputEvent components already.
UXML Traits is for creating your own custom types of UI Elements......thank god they removed it and made a literal on word attribute to replace no joke 20 or more lines of code.
Note the complete removal wasn't done till the 6.6 alpha, but the alpha with it removed is already published.
ah gotcha. I've been using the new input system so we might be okay in that regards I think.
sorry, would it be a lot to migrate UIDocument to UIPanel? or we can use both?
The only difference in set up is you have a method in a Panel Renderer called UIReloadCallback that you register a method to when you want to dynamically use the data from the UXML asset.
did they add a way to bind listitem in the ui lol
I feel like I saw something about that in patch notes for 6.5 and 6.6. I will have to check this morning to be sure.
how to prevent that element pushing other element beyond the container?, the left side is a textfield, and right is button and button, they are child of visual element with flex direction row,
Try enabling text wrap but I think label should have it on by default. I forget which option does that.
Otherwise perhaps auto text size.
set max width?
Question. I currently have this. Setup. each GO in the UI has a UIDocument and a relted Bootstrap script on it. And the planes are made like on the image. Basicly all share the setup. Now i kinda want to move to a one UIDocument system. Do i move it all to one panel using template or do i just copy paste from the #panel into the new UIDocument.
Is this ok?
Not really a good solution if you want to use flex layout properly
Fair xD
New to Ui toolkit. I am wondering what it is best for? When is a good time to use it over canvas stuff? When is it better to use canvas instead of ui toolkit?
I'm new to it too, but one thing I like a lot better than canvas is they support shader graph shaders a lot better
This is a good breakdown of each
https://docs.unity3d.com/6000.0/Documentation/Manual/UI-system-compare.html
The biggest value of UIToolkit for me is that it's not neccasarily GameObject/Component based, Which allows way more freedom in how you want to develop your UI based code
UI Toolkit can save "UIElements" as "Prefabs" or something like that right?
Say for example I have an interface to Edit the data of a Characters List, and each character is the be represented by an UIElement card with their info such as Name, Class, Exp and so on, so I could create new cards dinamically by hitting "Create new Character", this is possible, right?
Using the old Canvas System was it a regular occurency for a developer to have a Canvas with hundreds of nested GameObjects and whatnot?
You can define a template using either UXML or in code
(Or a combination of both)
wouldn't say hundreds, but yeah there can be a lot
and the most annoying thing about UGUI for me is the giant canvas in the scene that I have to keep enabling and disabling
Once they add navigation customization from the builder I will move over
Yes.
For me since im suing ECS to bridge them I have a custom SO that ecs system fills out and UIToolkit pars are binded to it using INotifyBindable (something like that) and just give it a template document and boom dynamic ui. And automatically binds data to each slot from the SO
Navigation customization?
yeah to be able to navigate the UI with arrow keys or joystick, currently you can't customize that trough UI builder you have to do it from code which is pretty painful
The GridView from AppUI package how easy is to add drag/drop to the slots? I have a template of the slot. And each "slot" is a entry in a SO array that is binded to GridView source
This should work at runtime as well
https://docs.unity3d.com/6000.4/Documentation/Manual/UIE-create-drag-and-drop-ui.html
App UI also has a node based Navigation editor. Though it's not as simple as I would like.
https://docs.unity3d.com/Packages/com.unity.dt.app-ui@2.2/manual/navigation.html
thats for page navigation not element navigation
max width is work, but i intent to add another more button there, so currently i need to calculate manually the size of textfield width, each added new button, is there any better way?
ah, you can set shrink/grow
set textfield width = grow so it will expand to fill the horizontal space
then set the buttons shrink/grow to 0 so it always stay the same size
ill try it
set the button flex shrink wont do the job, my textfield still pushing the button beyond the container
okay let me try something
is that a clear text button?
currently setting the width or max width of text field do the job, but as i said, if i need to add another button to it, i need to manually set the size of textfield
yes, so VisualElement(flex grow 1, dir row) has 2 child, text field(flex grow 1) and button
like this?
try to give input the textfield, until its fill up all the input space
ah
see if textfield are pushing the button
right now it just clips
just set width to auto then shrink 0 grow 1
(for text field I mean
here's the structure
.input-field__field {
flex-grow: 1;
width: auto;
flex-shrink: 0;
height: 26px;
}``` i dont know what make mine different then
are the 2 buttons inside text field?
no, its supposed to be the same as your, they are child of visual element as container
_mainContainer = new VisualElement();
_mainContainer.AddToClassList(ussClassName + "__main-container");
hierarchy.Add(_mainContainer);
_textField = new TextField(){label = "", isDelayed = true};
_textField.AddToClassList(ussClassName + "__field");
_textField.RegisterValueChangedCallback(OnValueChanged_TextField);
_mainContainer.Add(_textField);
_clearButton = new Button(iconImage: AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/File Creator/Graphics/Asset 17.png"), OnClick_Clear);
_clearButton.AddToClassList(ussClassName + "__clear-button");
_mainContainer.Add(_clearButton);
yeah š my bad
š
so still no easy solution -_-, im still need the recalculate width if added another button to it,
give me a min lol
when the text is really long, do you care if the button covers the end of the text. I know a quick workaround but I can look more into this lol
if possible, im expecting while its still on focus, the visible text is from the last text, then when lose focus it's either clip or ellipsis the last text, just like a normal text field does
while still respecting the width of button'
almost there lol
its respecting the container size?, does its no longer try to take more space where its shouldn't?
it's not but I'm working on a fix
go for it brother, im already giving up, i can just easily put it on the bottom, but the style just "ugly" for me
done lol
what u did?
textfield: width 100% width padding right button width x 2 = 50
button: wrapper position absolute right = 0
i just found a more easy fix
.input-field__field {
flex-grow: 1;
flex-shrink: 1;
min-width: 0;
height: 26px;
}``` setting min width to 0 somehow do the job
ikr, it's just not in my imagination, setting min width is the one i need
"it just works" - todd
thank's anyway
no problem š I didn't do anything. credit's all on you
anyone knows if its safe to add class to PanelRootElement?
I wanna use it like global style switching like dark/light mode for example, or different font for japanese for example
not sure if there is better way, ui themes? ui themes doesnt really seem good solution to me, if I want multiple global styles for difference concerns they would get messy I think
it would be nice If I could just switch one uss file of a theme during runtime
If it can accept classes then yea, otherwise the root element would be the place
yes I will give it a try, if it doesnt work I will have to add these to root element of each ui doc. UI Themes are what docs suggest for this as far as I know but not being able to edit them at runtime is deal breaker
Yea setting up styles with a single one to change it all works
but I have multiple global features so I would have to create combination, ui theme file for each combination
Maybe you can change stylesheets at runtime? I dont know how it will affect children though
https://docs.unity3d.com/6000.6/Documentation/ScriptReference/UIElements.VisualElementStyleSheetSet.html
love UITK š I just moved dev UI out from game window to editor window pretty painlessly
@shadow quartz Hey sorry for ping but I am testing 6.6 and I have some questions like setting initial state from code for simple animations(like start opacity from 0 from code when uxml doesnt have it) (this has been a problem with ui document too)
also is it possible to do srp batching yet?
is discussions go to place for these? should I create new thread there?
Going to start with the SRP batching question.
The new Panel Renderer inherits from the base Renderer class which is the main reason it has so many more features and benfits.
This does indeed allow for SRP batching for UI. Due note you can actually open up the Render Debugger now and the UI on a Panel Renderer should display all the information now allowing you see to the full information.
For the Animator thing Yelmond mentioned they are landing the animation support in pieces through out 6.6 alphas.
So some animation stuff you are looking for might not be out just yet, but coming over the next few weeks.
For animation stuff there is a flag in the project setting under the UI tab you have to set. Once that is set to true than animation for UI Toolkit is enabled.
Note after checking the enable UI Toolkit Animation checkmark you have to hit save and restart the editor for the new Animation tools to be enabled.
Here is a small clip showcasing that you can alrerady animate visual elements like any other object.
Thanks again!
I'll test Render Debugger but my custom USS filters drive per-element data via MaterialPropertyBlock (per the applySettingsCallback API for PostProcessingPass), which usually breaks SRP Batcher compatibility.
Is my approach wrong? I dont know too much about shaders so I did this mostly by vibe coding, of course I planned and go back and forth with uitk documentation.
Is there a path that works for filter shaders specifically?
I would have to see if RSUV fully is supported on UI Shaders. I am pretty sure it is based on the Renderer Pipeline so URP should support it for all shaders.
RSUV only allows setting a small amount of bytes on purpose though to allow it to change materials without breaking SRP Batching and also causing no CPU overhead.
Doesn't look like the Panel Renderer has had RSUV support added yet.
I will also test animator window but not sure if that fits my usage.
My problem in short:
- uxml element doesnt set opacity 0 but I wanna do uss transition from 0 to 1 when ui opens(has transition: opacity 0.5s ease-out on the element)
- Code sets element.style.opacity = 0 then element.style.opacity = 1
I guess because settings 0 and 1 happen at same time, the 0 gets ignored, element shows opacity 1 without transition.
my solution: just delay setting "element.style.opacity = 1" a 2-3 frames but would be better if there was a better solution
I could set initial value manually in uxml but opacity is just an example, sometimes there are more like scale so I dont wanna set initial state to uxml manually for each
Just sent a message for the UI Toolkit team about when RSUV for the UI ITself would be supported and same for custom filters.
Edit: Did it on the public forum for Panel Renderers for anyone also curious.
Thanks a lot š
I am assuming you are just using USS Transitions correct for the opcaity
yes, I just wanna trigger it from code but setting 0 then 1 in same frame doesnt work, it stays 1
Is this in C# code or the actual USS style file
c# code
the flow:
- delete uss transition from element(or just make duration 0) so next set is instant
- set opacity to 0
- add transition again
- set opacity 1
Is this a custom visual element or a built in one.
Oh are you getting the root element from the Panel Renderer
yea, register PanelRenderer.RegisterUIReloadCallback and use the rootElement
Which version are you using for the Unity Editor.
6000.6.0a5
OKay just making sure it wasn't the version with a certain bug.
the double attach event? I saw that on discussions, its not on this version?
Which of the two UIReloadCallback callllbacks are you using.
There is one with three parameters and one with two.
The 3-param versioned one ā (PanelRenderer renderer, VisualElement rootElement, int version)
Okay so not that issue either. I can try it in my project and see if I can get it to work.
its been like this on older versions too
This problem is only on first attach, as next ones we already set opacity to 0 so opening it again works fine
just the initial attach, I cant set initial state/styling from code
I guess best solution would be if I could dive in and edit uxml before it loaded?
I can do some testing after I finish some work stuff. I got to get ready for a work meeting, but I got a couple ideas to test out after the meeting.
okay thanks a lot, no rush š
Most cases would be just have the default style start the opacityat 0 with a style sheet and set the default transition duration there as well.
opacity: 0;
transition-property: opacity;
transition-duration: 1s;
I just want the comfort of just coding and forgetting, if there is no solution I will do this
like as developer experience, everytime I animate something I will have to manually add a uss class to that element to fix initial styling
The docu mentions I can use Monobehavior derived classes and bind them in the UI Builder. But I can't find it, it only gives me (Scriptable Object) or via Type I find it but the value is always empty.
Am I getting it wrong and it only works via script or uxml directly?
using UnityEngine;
namespace Code.Scripts.Arcade.Snake
{
public class ArcadeGameState : MonoBehaviour
{
[SerializeField]
int Score;
}
}
All I want basically is using this as a binding via UI Builder (as long as UI Builder can do that). Otherwise I just do it in the class it self
My bad missed that you already know SO binding
No worries
I think this is it
you then just have to provide runtime instance from code
uielement.dataSource = instance
it can be done in parent too, I think all child elements get the same datasource
I dont use it much but remember experimenting a few months ago
Thanks!! I hoped it would be possible just from UI Builder but I guess it makes sense to give the source at runtime.
Still lots of small problems that hurt the experience, but basic stuff works nice and I hate uGUI. Making my game fully on UITK + releasing the solutions on asset store. My main workarounds so far:
- Shaders/perf: no batching, so I bake static stuff (gradients, shadows) to textures. Shader at runtime only for elements I actually animate ā gradients, outer glow, etc.
- Transitions are fragile: not just initial-state collapse ā they also die mid-flight when PanelSettings internally re-attaches the panel root. Fix is delay/prime initial state AND animate on inner content elements, never the PanelRenderer's wrapper directly.
- No native animation/keyframe system: had to build my own sequencing on top of CSS transitions. The 6.6 alpha animation feature might help though, havent gave it a try yet.
- UI particles: render texture + camera pooling.
Committing early to 6.6, hoping it stays stable so I can focus on the actual game once the migration work is done.
Cant you just subscribe to on transitionend?
I do it for sequencing but my main problem is setting initial state from code, have to wait a frame to start the uss transition https://cdn.discordapp.com/attachments/892762498464374796/1508122898609471789/image.png?ex=6a15b5e6&is=6a146466&hm=ca2d9a972f0175b1d6bc8c54959a38b85218c4a51ca05ac76c086e8973427009&
i cant align them can someone help me?
Have you played around with dotween? They added uitk support
do this?
oh? I can check it out to see how they do it internally
DOTween is the evolution of HOTween, a Unity Tween Engine
I don't think they use the experimental stuff though
so might not be what you are looking for. but they have some UITK support stuff if you don't want to write things from scratch
Should I have a different UIDocument for each part of the UI? One for the Player Health and stuff, another for the Inventory, another for the Dialogue, etc...?
I think this was the intended use for the old Canvas and UI in general, right?
So I assume it is for the UIToolkit as well
Player Health is small so it could be a uxml used in another uxml. Like ui component in view.
I prefer thinking of each ui doc as a screen
Im not dumb but the button go down and the Restart go up
You would need to put the buttons in their own panel and have it flex horizontally
That's what I meant, sorry
Main visual element = vertical. Then the 2 buttons in the same element= horizontal like the above said
Hey, is ui toolkit āreadyā as a replacement for ugui? It looks like they intend to replace ugui with it at some point, so iām hesitant to start making a long term project using ugui, but at the same time it doesnāt feel like thereās a really āgoodā solution for some things you can do with ugui.
For example, a large skill tree. Itās a big window you can click & drag to move the view around (in one way or another, end result is it looks like the user is moving their view. Lets not get hung up on the specifics). It seems a bit ugly to do with UIToolkit⦠and to top it off, you canāt really make any tools to help with that. I.e. iāve made an editor window that helps me place ugui elements in the scene view so everything feels correctly spaced, much faster to iterate this way than manually placing things by hand.
I guess my question is, should I be trying to use UIToolkit for this? Most of the game will be UI, so I feel like I should, but it also feels like its missing a lot of parity with ugui. And if I should be using UIToolkit, how so?
scrollview?
I mean thereās still the fact iām not going to be able to make any sort of custom tooling to help speed up development
And I know that scroll view exists, but it still seems excessively ugly to manipulate this through UIToolkit, doesnāt it? Iāll have to be populating a list by getting elements through their names or through their assigned classes, both of which are strings. And itās discouraged everywhere to use strings to grab references to things⦠except the UIToolkit? This would be to set different buttons to enabled/disabled, etc.
I mean you can probably use both. I think UI Toolkit is better with data binding and materials but there's some place still for UGUI.
you can also maybe mix and match? xD
If using a list view you can set delegates for updating the elements and access by index.
You can make custom elements easier now which lets you directly ref or simplify references to child elements
And in 6.5 with the new inspector we can start to serialise references to elements themselves!
Is there a way to see what is causing UXML to not compile? I'm having errors everywhere, including in built-in Unity Editor UXML
I am using uitk fully, here is my view of biggest missing features but they can be done with some workarounds: #š§°āui-toolkit message
Your skill tree doesnt really sound a uitk/ugui problems, its just really custom and doable with both systems, just really custom
I've been hitting my head against the wall since yesterday trying to follow a tutorial and make a Pause menu that hides and shows itself
I finally managed to make it work like this
public void OpenEscMenu()
{
//root.visible = true; // This kinda works but the buttons remain totally visible the same
//root.style.visibility = Visibility.Visible; // This kinda works but the buttons remain totally visible the same
//root.SetEnabled(true); // This kinda works but the buttons just get greyed out
document.rootVisualElement.Q<VisualElement>("Root").visible = true; // Only this one worked
Debug.Log($"Root is called {root.name} and it has {root.childCount} children.");
Debug.Log($"Real Root is called {document.rootVisualElement.Q<VisualElement>("Root").name} and it has {document.rootVisualElement.Q<VisualElement>("Root").childCount} children.");
}
public void Resume(ClickEvent evt)
{
//root.visible = false; // This kinda works but the buttons remain totally visible the same
//root.style.visibility = Visibility.Hidden; // This kinda works but the buttons remain totally visible the same
//root.SetEnabled(false); // This kinda works but the buttons just get greyed out
document.rootVisualElement.Q<VisualElement>("Root").visible = false; // Only this one worked
}
The Debugs give me this:
Root is called Esc Menu Toolkit-container and it has 1 children.
Real Root is called Root and it has 3 children.
It seems to me that rootVisualElement does not return the object I think it does, is it the UXML? And why doesn't the other commented instructions work? The first one was from the tutorial and it worked there, it's only from 5 months ago
you should use styling, idk what visible is though
also SetEnabled is just a state
doesnt effect visibility, you cant click on button for example
_parentElement.style.opacity = visible ? 1f : 0f;
_parentElement.style.display = visible ? DisplayStyle.Flex : DisplayStyle.None;
first one doesnt affect layout
second one does
document.rootVisualElement.Q<VisualElement>("Root").style.visibility = Visibility.Visible;
document.rootVisualElement.Q<VisualElement>("Root").style.visibility = Visibility.Hidden;
This worked as well, what's the difference between them and this though?
document.rootVisualElement.Q<VisualElement>("Root").visible = true;
document.rootVisualElement.Q<VisualElement>("Root").visible = false;
If someone could explain to me that's be cool
Also what object document.rootVisualElement actually is, I still don't know
dont know about visible, styling opacity one just changes element opacity while DisplayStyle.None makes element disappear. So if you are in a flex layout, it would effect layout.
document.rootVisualElement is just where ui toolkit places your main uxml, a container but it can be destroyed on disable and recreated from scratch onenable
Tried both of these
document.rootVisualElement.Q<VisualElement>("Root").style.display = DisplayStyle.Flex/None;
document.rootVisualElement.style.display = DisplayStyle.Flex/None;
None of them worked
The only ones who are working are these
document.rootVisualElement.Q<VisualElement>("Root").visible = true/false;
document.rootVisualElement.Q<VisualElement>("Root").style.visibility = Visibility.Visible/Hidden;
Why is it that when I add padding to an Image it also afects the Image itself? Wasn't it supposed to be only its internal components? Do I need to create an empty Object inside of it just so I can affect only its children?
should work, maybe not on rootVisualElement directly but should work on your "Root", maybe you are doing it in wrong place/time somehow?
is that Image component? I just use background-image styling, shouldnt have this problem
I'm trying to figure out toolkit, and I'm struggling with getting a container to fill the whole screen without shrinking towards the top if the window gets too tall and narrow.
I've tried every combination of size (4K px size, 100%, auto) and flex (1, 0 grow, 1, 0 shrink).
Except for setting the size to 3840 x 2160, the visualElement (the red) doesn't show up in the game view (or build).
Using that size however, breaks the fill if the window is resized as mentioned above (there's only that one visualElement in the ui doc).
The panel settings are set to match width with reference resolution set to 4K. Stretching the window making it long and thin doesn't cause any problems.
Is there a way to let the red visualElement fill the screen in all cases?
I should mention the purple is the :root, which does fill the screen correctly.
It's confusing me why an empty visualElement doesn't fill it as well with 100% w/h (doesn't show up at all)
no other styling besides what I mentioned
and background colors
maybe try just flex: 1; but from what you say it should work already
is it the same as flex-grow/shrink?
if that's the case I did try both already
it also sets flex basis to 0
can you send screenshot of ui debugger?
showing styling of that element
yes but you are only showing inline styling
check this part
if anything else is effecting style it's here
the parent is also taking full height? if so idk, never had this bug myself
100% height doesnt mean screen, it means parent's height
the panel does, the root element also is being set to 0 height
check it on debugger?
yep.
Setting it to flex-grow 1 looks like a fix
but that is not an element I placed myself, and there don't seem to be anything letting me see it in the ui builder
thats normal, if parent doesnt have any styling it will have zero height unless content has fixed height
yes it works like this I think: panel has a element and then ui documents are it's child, your uxml is child of related ui document's element.
but it should be full size by default as far as I know
I am on 6.6 to test new features, by default it has this styling for full screen
:root
{
flex-grow: 1;
}
doesn't seem to have any effect on it
yes flex direction is one side only
you can copy this styling
when you do flex-grow 1 it grows in one direction only depending on flex-direction
flex direction is column
so it should be correct? I think?
but I'm not sure how I would apply the style to the root
:root doesn't seem to do anything
does it have any uss class unity adds by defualt?
nope
I think I've figured it out (or at least looks correct in game view now)
by giving style to .unity-ui-document__root
yes that should be the same
Yeah it looks fine in a build with weird window sizes as well now
thanks for the help, appreciate it a lot
npnp, what unity version are you using btw?
6.4
oh thats annoying lol I though it was older since this is just too simple to not solve
at least it's solved in 6.6, i guess they are just now focusing on runtime uitk stuff
it's probably a combination of me being generally ass at web-like ui and not using the default unity styles but a blank one
ohh
yea I have this
i just override unity styles but getting them from debugger was annoying work
should have mentioned I was using a blank one lmao
I had wrong assumptions on how the default works
I have 2 theme files