#πŸ§°β”ƒui-toolkit

1 messages Β· Page 26 of 1

rough scarab
little marsh
#

so they don't even support rendering the UI on RT?

#

well.. that kinda sucks for any VR use then πŸ˜„

rough scarab
#

I have no idea if you can manage to get it onto a RT currently, I haven't heard of anyone doing it, but I also haven't looked

#

I'm not personally planning on jumping into the "this is not a feature" territory of UIToolkit, it's burned me before πŸ˜„

little marsh
#

I just really dislike doing UI design work in actual scene, it's why I never wanted to use UGUI in the first place πŸ™‚

#

but yeah probably not the best idea to jump into "not yet supported" territory still 😁

rough scarab
#

Oh I totally agree that UIToolkit will be great and UIBuilder is a much better place. I'm just only transitioning for things where I know I am almost completely covered by UITK's offerings

#

UGUI is hell hcjTrash

static canyon
#

The main issue with using it in WorldSpace is the events - you used to have to hack a solution together especially if you're doing VR. Not sure on the current best practice though. Depends which input system you're using too I think.

tulip sparrow
#

is there a way for me to satisfy this error when creating PanelSettings from code?

#

guess I could just create a UIDocument prefab with the PanelSettings already saved

tame wadi
#

Is using the Resources folder for uxml/uss acceptable?

#

Oh it looks like there is no support for StreamingAssets loading raw uxml at runtime, so you have to use AssetBundle or Resources

#

And since UI assets are generally lightweight Resources is probably acceptable

tulip sparrow
# tame wadi Is using the Resources folder for uxml/uss acceptable?

acceptable? That is debatable. Some people consider not using resources folder at all is the only acceptable route, someone say barely use it, some say who cares use it as much as you want. I personally don't use it at all. If you are wanting to use "resources" in editor, there is also Editor Default Resources folder special name that EditorUtility.Load goes directly to first

#

As I haven't actually released anything yet though, unfortunately my knowledge fully on the resource and streamingassets folders are limited

tame wadi
#

but yea they say... "dont use it" under the resources section πŸ˜…

tulip sparrow
#

I have been working pretty hard on basically creating everything from code as much as possible, even my textures and stuff. So, I don't have a lot of things included to take advantage of things like the streamingasset folder

tame wadi
#

although under the "proper uses" section uxml does kind of fall into all of those categories

#

its ubiquitous, not memory intensive since its just ascii, doesnt vary that much across platforms

tulip sparrow
# tame wadi although under the "proper uses" section uxml does kind of fall into all of thos...

I don't know the best way for UI stuff either, speaking of loading, it was kinda something I was just looking up, but, in my effort to not use resources folder, I ended up doing 2 things. I've made a ScriptableObject which I'll show in a second cause I actually have questions on it, that has RuntimeInitializeOnLoadMethod attribute, for basically UI, and a base prefab that contains a UIDocument

#

the prefab was mostly to stop the above Theme Style error

#

but realized I could probably just use 1 prefab object and manipulate it a lot for my needs

tame wadi
tulip sparrow
tame wadi
#

I suppose you get true live reload that way? heh

tulip sparrow
#

but all my UI is base visual elements, with different pieces atm that depending on the complexities of what they need are custom built from visual elements, or, something like dropdown (eventually hope to have them all custom, but, being a solo programmer, it's a get to thing). Then some of them have UXMLFactory and traits so they can also be used in UIBuilder if so desired, or to print out the code in that way

tame wadi
#

do you see a preview of component in UI builder if there is no uxml?

tulip sparrow
tame wadi
#

so last night I refactored most of my ui to use templates in uxml, but now im considering another refactor to custom elements and UXMLFactory

#

i dont really like the <AttributeOverrides ... stuff in uxml

#

feels clunky

tulip sparrow
#

yeah, I didn't like how it was setup also. Not that it is bad persea, just that it doesn't flow naturally with all the different things Unity teaches

tame wadi
#

the uxmlfactory stuff seems really nice though, and the integration with the uibuilder is sweet

#

so now you've kind of convinced me that i should do that lol

#

I actually had no idea about custom elements at first, but after copy/pasting a bunch of times to update multiple instances I was like okay there has to be a way to componentize this stuff

tulip sparrow
#

basically you setup all your stuff like normal through c# then use the UXML factory to initiate through that rather than... itself?(Idk if that is the right word)

tame wadi
#

And unfortunately I didn't stumble on uxmlfactory until after I had refactored to use templates, since that seems to be the primary docs they have around reusability

static canyon
#

Imo Resources is ok - just not great at scale or if making an asset across multiple projects. Think the most common way (and method I usually use for runtime stuff) is to just have a monobehaviour in a scene reference them.

magic orbit
#

what is tooltip

#

in ui toolkit?

#

i want to change a selector/group of buttons in a ui

#

via script

tulip sparrow
magic orbit
#

like, if a button from this group is clicked, something happens

tulip sparrow
# magic orbit via script

no, more like lets say you have a section of UI with text that fills up [abcdefghijk]lmnopqrstuvwxyz where the brackets are the space. Tooltip makes it so the lmnopqrstuvwxyz would be visible when you hover over it. Maybe even more letters because I think with tooltip enabled it ends with ...

magic orbit
#

i asked because i thought tooltip is what i needed

#

but i think its unrelated

tulip sparrow
unborn bluff
#

Hello

magic orbit
#

wha

#

is there radio button

tulip sparrow
#

also, clickable.activators is how you edit the button after created

magic orbit
#

i see toggle, but not radio buttons

tulip sparrow
#

what version are you on?

magic orbit
tulip sparrow
#

also, if you don't have it, shouldn't be too hard to track with a ChangeEvent<bool>

magic orbit
#

is it not supposed to show up in the builder then?

#

how do you use it

#

are you writing xml and uss

tulip sparrow
#

let me look at my builder rq

#

yeah you must be on an older version

#

2021.2 uibuilder has radio and radio button group in default

magic orbit
#

what the

#

ill update it here then

#

but i downloaded it like

#

2 days ago

#

how do i update it?

#

mine is this version i thinkl

tulip sparrow
#

no idea on the packages, in 2021.2 this is default built in, so don't have those even installed to check, but try doing a com.unity.ui to make sure everything is up to date?

#

in your github link in package manager

magic orbit
#

ok

#

w

#

that broke my unity for some reason

#

it happened the first time too

tulip sparrow
#

that has happened to me sometimes. I just restart Unity

wide sluice
wide sluice
#

I mean, the input system's been around for 3 years now, and we still can't use the UI Toolkit with it (at least as far as I know)

still lantern
tulip sparrow
rough scarab
#

2022.1.0a15

UI Toolkit: BoundsField, BoundsIntField, DoubleField, FloatField, Hash128Field, IntegerField, LongField, RectField, RectIntField, Vector2Field, Vector3Field, Vector4Field, Vector2IntField and Vector3IntField are now usable in Runtime

tulip sparrow
umbral zodiac
tulip sparrow
#

do I need to do more than just .Remove to get rid of a UIElement?

rough scarab
#

Nope, it's just plain old C#, so it'll get garbage collected when you release the references

tulip sparrow
#

can I get your guys opinion. I'm not sure how I should handle the text overflow, if I should wrap, or just tooltip, or what would be the best route

tame wadi
#

I just finished refactoring my templates to custom elements and I am much happier with it now. I also made some really low level wrappers around button/text that basically just override text property to hook into localization, so much happier with that too.

still lantern
tulip sparrow
still lantern
# tulip sparrow 2021.2.2f1

Oh then the Label has a ellipsis bool that will also automatically add a tooltip showing the full name too (can be toggled off)

sacred quarry
#

How do we modify the Clipping of an element? I have a foldout that I want to shrink so only the arrow is clickable, but it's clipping the children out. Can I fix that?

tulip sparrow
tulip sparrow
sacred quarry
#

Is there a way to stop elements from Inheriting style data? I'm manually indenting some elements and the content wrapper element is adding additional indentation at each child level.

tulip sparrow
# sacred quarry Is there a way to stop elements from Inheriting style data? I'm manually indenti...

everything has a default layout it is layed out in. From my understanding, you need to set it yourself. The repetitiveness of this though can be solved from many fronts. One way as an extension method that has the styles you want to "override". Another way is a just a container of sorts like a new class called StyleSettings or something. The other is your own custom visual element. You can also do all this through your own stylesheet if your want

sacred quarry
#

I'm doing everything inline with the class constructor right now

#

I don't see a StyleSettings for the element, just style and resolvedStyle, which is unclear what it is.

tulip sparrow
# sacred quarry I'm doing everything inline with the class constructor right now

yeah, in this way then I would probably recommend doing a custom class visual element, and add on extension methods for ease of changing specific things that might be outside of your normal defaults. For example,

  public static IStyle ResetPadding(this IStyle style)
  {
    style.paddingBottom = 0;
    style.paddingLeft = 0;
    style.paddingRight = 0;
    style.paddingTop = 0;
    return style;
  }
sacred quarry
#

Hmm, well I can reset the margin to 0 and it won't keep increasing when nested, but the uncontrollable clipping returns again....

tulip sparrow
sacred quarry
#

Yeah I tried setting that to the parent element ScrollView but it didn't seem to do anything for the clipping. Seems like the inheritance on element style is not stable or something.

#

Ended up digging through the elements with Q<> to manually fix the margin down the chain. Still not sure about the clipping though. Margin seems like the only fix, but it's not even related.

sacred quarry
#

Eh, just yolo'd the button width until it was clipped by the parent panel. Looks fine. I think this could also be something with the way the Foldout manages the sizes and indentations too, causing some weird results when you're trying to add things with absolute positions and stuff...

tame wadi
#

I would highly suggest not using inline styles and trying out stylesheets instead. The inspector is nice for tweaking stuff to see what you want your final values to be, but I would roll those changes back into a stylesheet somewhere.

#

UI toolkit takes direct inspiration from html/css, and people in the web world stay away from inline styling as much as possible.

#

And you may be tempted to use # selectors to target names but I would instead add a class and use that as a selector. I try to use # for scripting query lookups only.

tulip sparrow
tulip sparrow
tame wadi
#

Half of the reason for me using uss is that I get my ide tooling and syntax highlighting etc.

#

And classes aren’t just for if you need to apply the styling to multiple elements. It’s perfectly acceptable to have a class selector that is only applied to a single element.

tulip sparrow
#

is there a way to create a rootvisualelement without UIDocument? I understand that the UI system relies on a root visual element, but, I'm not entirely sure what that root visual element is doing to draw? I've checked out GL and Graphics classes, but, that was getting into some entirely new things I'm not ready to learn just yet

tulip sparrow
#

Just random tip if anyone else was curious, margin is outside the element, padding is inside the element

tulip sparrow
#

have any of you messed with changing the cursor style? I'm not quite sure how to do it

tulip sparrow
#

am I handling callbacks correctly?

    bool isOut;
    bool isDown;

    void OnPointerOverEvent(PointerOverEvent e)
    {
        isOut = false;
        RegisterCallback<PointerOutEvent>(OnPointerOutEvent);
        RegisterCallback<PointerDownEvent>(OnPointerDownEvent);
    }

    void OnPointerOutEvent(PointerOutEvent e)
    {
        isOut = true;
        if (!isDown)
        {
            UnregisterCallback<PointerOutEvent>(OnPointerOutEvent);
            UnregisterCallback<PointerDownEvent>(OnPointerDownEvent);
        }
    }

    void OnPointerDownEvent(PointerDownEvent e)
    {
        isDown = true;
        RegisterCallback<PointerMoveEvent>(OnPointerMoveEvent);
    }

    void OnPointerUpEvent(PointerUpEvent e)
    {
        isDown = false;
        UnregisterCallback<PointerMoveEvent>(OnPointerMoveEvent);
        if (isOut)
        {
            UnregisterCallback<PointerOutEvent>(OnPointerOutEvent);
            UnregisterCallback<PointerDownEvent>(OnPointerDownEvent);
        }
    }

    void OnPointerMoveEvent(PointerMoveEvent e)
    {
    }
still lantern
tulip sparrow
still lantern
#

If I need to toggle behavior of some type I use bools fields in the class instead of registering/unregistering events. This also seems to be the approach Unity takes with all of their internal systems/implementations.

tulip sparrow
#

for example

still lantern
tulip sparrow
tulip sparrow
tulip sparrow
#

so I'm getting it to work pretty well, just need to figure out how to better deal with the events if dragging while it leaves element

#

oh maybe I need to use capturemouse while mouse is down

#

then MouseCaptureController.ReleaseMouse() on mouseup

tulip sparrow
#

if I'm to drag a window to expand left or up is there an easier way than what I'm currently doing to change the height and width? When dragging down or right I easily just change the width or height. For up and left I've had to make it so it is changing the position of the UI and increase/decreasing the height/width

#

basically, is there a way for me to change the pivot

#

well let me checkout this domeasure

tulip sparrow
#

So I'm trying to figure out a better way to approach adjusting the top and left size of a UI window. The way I listed above causes some jittering

#

I found somewhat of a way by adjust the padding, however, I didn't know if I should keep this route just because of having to add an extra variable in calculating width/height

tulip sparrow
#

basically doing something like

        parent.style.marginTop = parent.style.marginTop.value.value + e.deltaPosition.y;
        parent.style.height = parent.style.height.value.value - e.deltaPosition.y;

in all the respective borders, but as you can see I still have a little jittering. Not sure if anyone has any thoughts on that?

#

maybe I should calculate any changes before doing the changes and then use Mathf.Approximately?

still lantern
tulip sparrow
#

Adding a default 9pane container for example into my base containers, with a size container override. Then I think I can abuse absolute position while maintaining relative for auto layout

tulip sparrow
#

how do I better keep track of the layout phase, is that the IMGUI layout phase?

tulip sparrow
#

Not toolkit related, sorry

exotic coral
tulip sparrow
#

can anyone better help me understand how to register changed events? I thought I had it down, but, apparently not. I'm trying to register value changes for height and width of a main container to adjust the border containers accordingly. The way I have it setup right now i something like

    protected override void ExecuteDefaultAction(EventBase evt)
    {
        base.ExecuteDefaultAction(evt);
        if (evt.eventTypeId == GeometryChangedEvent.TypeId())
        {
            if (evt.target == this)
            {
                UpdateBorders();
            }
        }
    }

    public void UpdateBorders()
    {
        UpdateBottom();
        UpdateLeft();
        UpdateRight();
        UpdateTop();
    }

It works, but, I was thinking that I didn't need to run through all of these every time a size change happens and instead specifically target the exact thing based off value changes

still lantern
unborn bluff
#

can I add a UIDocument to a MonoBehaviour without showing it? I want to do this so that I can use its CloneTree method and add its elements to the main game frame. Am I doing this the wrong way?

tulip sparrow
still lantern
#

And yeah, you would do new !=old. But I think the event may have a enum for the type.

tulip sparrow
#

however, it comes after registering callbacks, so you can use a callback if specifically needed and cancel default action

#

like, I started doing

    protected override void ExecuteDefaultAction(EventBase evt)
    {
        base.ExecuteDefaultAction(evt);
        if (evt.eventTypeId == PointerDownEvent.TypeId())
        {
            RegisterCallback<PointerMoveEvent>(OnPointerMoveEvent);
            this.CapturePointer(PointerId.mousePointerId);
        }
        if (evt.eventTypeId == PointerUpEvent.TypeId())
        {
            UnregisterCallback<PointerMoveEvent>(OnPointerMoveEvent);
            this.ReleasePointer(PointerId.mousePointerId);
        }
    }

    void OnPointerMoveEvent(PointerMoveEvent e)
    {
        parent.parent.style.marginLeft = parent.parent.style.marginLeft.value.value + e.deltaPosition.x;
        parent.parent.style.width = parent.parent.style.width.value.value - e.deltaPosition.x;
    }

instead

#

also

#

I didn't know how to really use PointerMoveEvent inside the default action.

still lantern
#

This does not look what you should be doing, but maybe you have a good reason...?

tulip sparrow
still lantern
#

From the bits of the code you have shown make me think that it is rather messy and not exactly how you are meant to be doing things.

tulip sparrow
still lantern
#

It does exactly what you are doing from what I understand.

tulip sparrow
#

I think I'm doing it how they intended. The UIToolkit seems to be built on this idea that everything is a "container" for things you want to do. So, in this screenshot for example, everything you see is it's own visual element, with minimal code inside of it, then it's all in essentially an overlay container on top of a content container

still lantern
tulip sparrow
#

cool let me check that out

tulip sparrow
still lantern
tulip sparrow
#

part of my problem is IDK which element should be the element that essentially handles events?

#

Like, if I want to change a child elements size, is it better to handle that in the parent, or the element itself

tulip sparrow
#

Also, do you know how to use public UIElements.StyleCursor cursor;? Some of these styles I'm confused how to edit. I ended up using a button with a unicode code in the text because idk how to edit the istyle cursor lol

still lantern
tulip sparrow
#

I guess mostly, what I'm struggling with is how I generate a texture from a unicode text

tulip sparrow
#
    public static UnityEngine.UIElements.Cursor TestCursor()
    {
        UnityEngine.UIElements.Cursor cursor = new UnityEngine.UIElements.Cursor();
        cursor.hotspot = Vector2.zero;
        Texture2D cursorTexture = new Texture2D(20, 20, TextureFormat.RGBA32, false);
        cursorTexture.alphaIsTransparency = false;
        for (int x = 0; x <= cursorTexture.width; x++)
        {
            for (int y = 0; y <= cursorTexture.height; y++)
            {
                cursorTexture.SetPixel(x, y, new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f)));
            }
        }
        cursorTexture.Apply();
        cursor.texture = cursorTexture;
        return cursor;
    }
magic orbit
#

Hey there, Unity keeps giving me this error namespace or class "UIDocument" can not be found.

#

this is the line of code giving me this error

#

but as you can see, UIDocument exists

#

it's identified inside of vscode

#

actually, I can always fix the problem when I edit the code (without changing anything), but this error always show up when I open the editor

#

what's causing this? how do I fix it?

tulip sparrow
#

I haven't messed around really with those yet as every time I do I seem to use them wrong, so, that is unfortunately the extent of my knowledge

tulip sparrow
#

Is there a native way to cancel mouse events in general if using pointer events?

#

Or, I guess. Is there a way for me to lock the cursor icon while pointer capturing?

static canyon
#

Another more common approach might be to match the border position with the cursor position.

tulip sparrow
tulip sparrow
#

I'm actually confused by how e.originalMousePosition even works. The top is the position it gives me, the bottom is an example of what `Input.mousePosition gives me.

#

e.position just seems to return originalMousePosition as a vector3, so does no help. e.localPosition returns the distance of the cursor from the element doing the event, which is probably what I'm looking for, however, still leads me the confused on the previous 2

#

probably why delta position isn't moving with my cursor. It's probably being calculated on wrong positions

#

for example of another check

still lantern
#

@tulip sparrow Just thought I would say thanks for mentioning element.CaptureMouse() the other day, I needed to implement a version of what you are doing today and because I saw you mention it it was at the top of my mind. Saved me a lot of time haha.

still lantern
tulip sparrow
tulip sparrow
still lantern
tulip sparrow
#

okay, I think I notice the problem. It might not be the same in an actual build, but, I think the input.mousePosition was giving me coordinates based on my actual screen resolution, and not just the game view?

tulip sparrow
#

IDK how to test it, but, is referencing 2 parents up in UIElements like parent.parent.style.translate = new Translate(parent.parent.style.translate.value.x.value + offset.x, parent.parent.style.translate.value.y.value + offset.y, parent.parent.style.translate.value.z); better than doing .Q()?

tulip sparrow
#

btw, I changed the move event to

    void OnPointerMoveEvent(PointerMoveEvent e)
    {
        Vector2 offset = e.originalMousePosition - position;
        position = e.originalMousePosition;
        if (offset.x < 0 && offset.y > 0) style.cursor = UICursors.ExpandArrowDiagonalForwardLeft();
        if (offset.x > 0 && offset.y < 0) style.cursor = UICursors.ExpandArrowDiagonalForwardRight();
        parent.parent.style.translate = new Translate(parent.parent.style.translate.value.x.value + offset.x, parent.parent.style.translate.value.y.value, parent.parent.style.translate.value.z);
        parent.parent.style.height = parent.parent.style.height.value.value + offset.y;
        parent.parent.style.width = parent.parent.style.width.value.value - offset.x;
    }

and works really well now. The cursor is never not on the element while moving now

#

need to just update it on all my border visual element now

stray nexus
#

hi i am using ui builder and i created an UI document but i dont have this event system component, anyone knows why?

tulip sparrow
stray nexus
tulip sparrow
stray nexus
#

wait i think only works on 2020.2 not .3

#

which one you use?

tulip sparrow
stray gull
#

ehm, is it okay if I ask here about UI Builder messing with me pretty bad, or is this strictly for design advice?

stray gull
#

alrighty then...

#

so, every time I re-open my project, the script in UIDocument stops working, tells me to check for compile errors, which there are not any

#

and I have to delete the script, create an identical one, attach it to the UI Document again

#

and it works... until I close unity again

#

rinse repeat over and over

#

its super confusing

#

as everything is working fine, until I close unity

#

this is what it looks like after re-opening unity

tulip sparrow
#

Unfortunately, I don't understand much outside of that yet, I just know it's the issue because I had that issue on earlier versions

stray gull
#

oh man, ok I will look into it

#

thanks

tulip sparrow
# stray gull oh man, ok I will look into it

from the very little I found basically you use them to tell the order of assemblies you want loaded, but, I'm confused on if you use one, does that mean you need to start including all assemblies? Last I checked, the default unity was using like 162 assemblies? I think, so, IDK lol

stray gull
#

Oh thanks for the effort

#

I decided to go to bed angrily

#

It is an issue for tommorow's me

stray gull
#

in the folder where the script handling the UI is located, I created an assembly definition

#

the name of the assembly definition is the same as the name of the folder it is in

#

after that it still was not working, so in the assembly definition menu in the inspector, I clicked on add reference

#

and there I added all the assemblies containing 'ui'

#

probably not the best solution

#

but its working Β―_(ツ)_/Β―

faint yacht
#

Hello! Is there any guides that provide like starting experience for code-only UI Toolkit usage? I've found only the ones that use UI Builder, but i'm actually kinda experienced in web development and HTML + CSS, find them pretty comfortable so i want to grasp the code-only way. Just have no idea where to start.

tulip sparrow
tulip sparrow
#

I'm actually in the process of trying to create a webGL unity UI playground. I don't feel comfortable sharing it yet, and wondering if I ever will lol, but maybe you gave me extra excitement to do so

faint yacht
#

does it even worth using UI Toolkit with 2020.3.22f1 version tho?

tulip sparrow
#

I don't really know what is included from updating the UIToolkit package, vs built in

stray gull
#

so far its ok.... except for the issue I explained above but I have no clue if the same is going to happen to you

tulip sparrow
#

isn't

        public static bool operator ==(StyleLength lhs, StyleLength rhs);
        public static bool operator !=(StyleLength lhs, StyleLength rhs);

suppose to let me validate if one of these style structs is null or not?

#

I can use Debug.Log(parent.style.width.keyword == StyleKeyword.Null); as an example, but, thought I could just do without with operators

#

I also haven't been using StyleKeyword like anywhere, so, IDK if it's only values by default are StyleKeyword.Null and StyleKeyword.Undefined on values that aren't null. Basically, if it is a valid thing to check against only if I specifically set it

stray nexus
#

all these errors while trying to install ui toolkit on unity 2020.1.9f1
whats this? i already tried other version i always have errors when trying to install this

tulip sparrow
#

I hate how I keep starting out with like 10 visual elements to learn how I want to build something, then condense it to like 1-3 visual elements once I figure out what I want lol

tulip sparrow
#

between the direction textures read, and differences between absolute/relatives starting points and direction, etc... position is so annoying sometimes. No wonder they recommend auto layout lol

tulip sparrow
#

can anyone tell me if in the most recent unity they make dealing with IStyle properties less obnoxious before I make a bunch of extension methods?

still lantern
tulip sparrow
# still lantern What are you doing right now?

I just got frustrated with typing out all of StyleTranslate stuff when resolvedStyle isn't good enough. So just did

    public static StyleTranslate @Translate(this StyleTranslate styleTranslate, Vector2 value)
    {
        float x = styleTranslate.value.x.value + value.x;
        float y = styleTranslate.value.y.value + value.y;
        float z = styleTranslate.value.z;
        styleTranslate = new Translate(x, y, z);
        return styleTranslate;
    }

to save me some time

tulip sparrow
#

I created a container I call my "Interaction Container". To leave it as generic as possible I created a new delegate to notify a listening of when that element is clicked, however, I wanted to check if there was an event that already happens that I should use instead? To clarify also, I do use PointerDownEvent. I'm trying not to use that specifically though for this case because I'm trying not to directly make a visual element rely on another. Oh, and I have picking mode off on the overlay I want to bug about this.

#

I was going to use SendEvent, but, I wasn't quite understanding it yet it seems

#

better yet, is it better to just cancel default actions on visual elements and use your own delegates for any reason?

#

for example, I just did

    public delegate void OnInteract(EventBase evt);
    public OnInteract interactMethod;

with

        if (evt.eventTypeId == PointerDownEvent.TypeId())
        {
            pointerPosition = evt.originalMousePosition;
            this.CapturePointer(PointerId.mousePointerId);
            if (interactMethod != null) interactMethod(evt);
        }

do I need to care about BubbleUp and TrickleDown at all?

magic orbit
#

sucks

#

i just fixed this problem, my team almost gave up on using uitoolkit because of that

#

in fact, it's so inconsistent to the point that sometimes it would work, for some people it would work

#

while for others this problem popping up

#

in fact, you didn't even need to delete and recreate the thingy, if you just edited some script (like added a comment or something that makes no difference at all), saved, and then went back to unity and waited for recompilation, it would suddenly work

#

the solution you found is how to deal with it really

#

assembly definitions

stray gull
#

yep it sure does suck

#

was stuck on it for a while

#

its the type of thing thats so demorilising that it makes you lose all the drive you had to work on your project

#

for me that is, at least

tulip sparrow
#

Controlling assembly loading is a necessity long term. It sucks when something happens outside of the normal scope that would cause huge headaches if you aren't at that level you. There is a reason

UI Toolkit is built into Unity as a core part of the Editor. It is also available in this package, com.unity.ui, which is currently in preview. The built-in version for each major Unity release is based on a specific version of this package, but the two are not completely identical.
is on the UI Toolkit page.
Unity compiles scripts in 4 separate phases. You can actually cause this issue yourself as your project gets larger if you start taking advantage of assembly definitions in an effort to condense load while still having access to everything you want.

#

Also, IDK what version you guys are on, but, when I jumped off the LTS, all my UIToolkit problems went away XD

rough scarab
#

There's also a migration guide pinned to this channel for going from earlier preview versions to later ones, or to 2021.1

tulip sparrow
#

yeah, I forget to mention the pins

faint yacht
#

Is it possible to serialize UI Toolkit Image class for runtime so i can add icons for my interface with drag & drop?

#

I want to add icon field for my MonoBehaviour items on scene,that would then display in player's inventory.

tulip sparrow
#

Image already exists for runtime. Even if it didn't, you can change a visual elements Style.backgroundImage

#

ATM You have to use UIDocument to display visual elements since they require having a "root" to display in. Unfortunately, I haven't gone further into figuring out more than that since it is pretty simple. Just make sure a UIDocument Game Object exists when you game starts and make it the size of your screen. I personally haven't had a situation yet where you would need more than 1 UIDocument. In fact, I wish Unity just removed the GameObject all together, made it always the size of the screen, and made it just built into builds

#

Then make rootVisualElement just some base in the UnityEngine library

faint yacht
#

I've asked how could i set Image typed field of a class in the inspector, ATM it doesn't seem to serialize it

#

and what could i use instead then

tulip sparrow
#

also, make sure you are serializing it πŸ˜›

faint yacht
faint yacht
#

it doesn't seem to show up in the inspector any way

tulip sparrow
faint yacht
#

but i'll try this one, one second

tulip sparrow
#

ScriptableObjects and MonoBehaviours are default Serializable, so, you shouldn't need to include it on those, but on other stuff you do

faint yacht
tulip sparrow
#

statics aren't serializable either. Personally, I just stop messing with serialized or not and just make accessors that editor can get values from and display it regardless

tulip sparrow
#

also, try posting a SS of your code if you get a second

faint yacht
tulip sparrow
#

seeing that code will make it a lot easier to diagnose

faint yacht
#

just expecting the icon field to show up in the editor

#

so i could put the image to it, and then use this icon in the UI

#

same thing did work with basic unity UI, but doesn't with UIElements

tulip sparrow
#

You can't drag and drop UIElements in this way natively

faint yacht
tulip sparrow
tulip sparrow
#

if you want to get fancy, you can delve into making that field visible in the inspector, but, for simplicity, you should be able to natively drag and drop into a Serialized Texture field

magic orbit
#

text disappeared

#

why

tulip sparrow
magic orbit
#

yes

#

they show up in the ui editor

#

but they dont on the game

tulip sparrow
magic orbit
#

no

tulip sparrow
#

also, can you click on the text field? value needs to be set for text to show

magic orbit
#

yes

#

they really do show up in the editor

#

hold on

tulip sparrow
#

a change event has to be registered to

#

yeah, but, you can type things into a text field in editor without it saving

#

Changing text by itself doesn't save it

#

you need to go through the normals steps to save the value, or, automate it registering to ChangeEvent

magic orbit
tulip sparrow
#

Yes. Go to wherever you initialize the element in game, add whatever.value = "login" for example, and whatever.value = "******"

magic orbit
#

but the button text is not showing up

#

nor any label

tulip sparrow
#

Yes, again, the values DO NOT JUST SAVE

#

because you typed something into them

magic orbit
#

but that doesn't make sense, i made 3-4 other ui and never had that issue

tulip sparrow
#

for example, with the button,

Changing this value will implicitly invoke the INotifyValueChanged{T}.value setter, which will raise a ChangeEvent_1 of type string
so you can automate saving it through this by default

#

or initialize the UI with the text you want

tulip sparrow
#

if you are using PropertyField to change things, that is a different story. I'm not fully aware if it replicates SerializedObject and SerializedProperty in their entirety, but, says, A SerializedProperty wrapper VisualElement that, on Bind(), will generate the correct field elements with the correct bindingPaths which may be automagically doing setdirty type things for you

magic orbit
#

im not using any code anywhere

#

i just made the thingy

tulip sparrow
tulip sparrow
magic orbit
#

ahmm

#

probably

#

ill check if the other UI's are showing up

tulip sparrow
#

text != value

magic orbit
#

hey

magic orbit
#

i think i figured the source of the problem

#

yesterday i was having a massive issue, which was such a pain

#

type or namespace "UiDocument" could not be found

#

so I followed a tutorial and created an assembly definition

#

and this assembly definition

#

had this setting

#

in order to work

#

now I feel like fonts are not showing up or there's no font on the runtime

#

no text show up, at all

#

that could be the reason, but the solution, no idea

tulip sparrow
#

can someone help me better understand how to deal with events with trickledown and bubbleup? Most the time it feels like dealing with them is far less efficient than directly telling the element to grow up and be a big boy

#

Just as a premise, I'm working more on my ability to expand a UIElement any direction regardless of it's parents settings. Doing so is making have to wait on GeometryChangedEvent and AttachToPanelEvent for example, to guarantee certain steps have happened first and not skipped over. Easy enough to not use the default UIElement event system, but, I feel like that undermines the purpose and I just don't get how to use it yet fully

still lantern
tulip sparrow
#

and I feel like I concluded it is almost always better to just ignore the trickledown/bubbleup, but, I also don't use any xml and do all of my UIToolkit in C#

#

so idk if that is something that is beneficial there or?

#

what does

Style sheets also have features that aren’t possible to use with inline styles, like:

Pseudo states like :hover, which will apply some style properties to an element when you hover over it with the mouse.
Styling of elements inside a read-only hierarchy inside a Template Instance (instance of another UI Document (UXML)) or custom C# element that creates an internal hierarchy. You can style elements with style sheets using hierarchical USS Selectors, like the following
even mean? I literally am doing these things right now

still lantern
rough scarab
#

It doesn't mean that you cannot do it "in code", it just means that inline styles themselves do not have any support for those things

tulip sparrow
#

ohh gotcha, okay, cause was like, all elements, even with picking mode on false, receive in and out events, which is a literal trigger for hover events

still lantern
#

An example is the :selected pseudo state.

tulip sparrow
#

all elements have defaultaction for in and out unless coded not to

#

as far as I can tell, without picking mode set to false, all elements have the in/out/enter/leave/up/down/click default actions, and with picking mode true, just enter/leave

still lantern
#

Yes that is correct.

tulip sparrow
#

rather, not false and true, but position and ignore

still lantern
#

ignore means that it cannot be 'picked'/'clicked' by the mouse/pointer

rough scarab
#

It'll be cool if/when they add the more complex selectors that CSS has and is continually getting

#

I hate how CSS works for layout and has a lot of incompatible nonsense, but the selectors are really nice

tulip sparrow
#

IDK if it will be of any use, and if I'll ever even finish it, but, I'm trying to make something like the yoga playground atm with UIToolkit

#

my goal is people will be able to download C# file for UIToolkit they can use in their projects

#

we will see though

red star
#

Hi all, I want to make a L shape button. But I only can make rectangle touch zone of it. Anyone have idea to make it? Is UI Toolkit have some thing like alphaHitTestMinimumThreshold ? Thank you πŸ™‚

tulip sparrow
#

if you aren't on a version that has a RadioButton, just use 2 buttons and connect them

red star
#

Do we have plan to support alphaHitTest in future?

tulip sparrow
red star
# tulip sparrow Unfortunately I don't know, and IDK what alphaHitTest is, however, I know you ca...

Ah, sorry, before, we use this feature for custom shape buttons https://docs.unity3d.com/2018.1/Documentation/ScriptReference/UI.Image-alphaHitTestMinimumThreshold.html. If use touch on a alpha part of rectangle image, we consider it is not a hit. https://forum.unity.com/threads/none-rectangle-shaped-button.263684/

#

btw, thank you for your support πŸ™‚

magic orbit
#

whats that

hazy rivet
#

Anyone else notice that the Inspector's updating of values is a huge drain on Editor performance in Play mode?

slender token
#

Are there any gotchas with creating custom elements that using uxml files as templates.
I'm not sure if I understand how it supposed to be working.

Like I can create an element like this:

public class CustomElement : VisualElement
{
    public CustomElement()
    {
        var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/element.uxml");
        template.CloneTree(this);
    }
    
    public new class UxmlFactory : UxmlFactory<CustomElement, UxmlTraits> { }
}

and the uxml is very simple:

<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
    <ui:VisualElement />
</ui:UXML>

it basically just single VisualElement. but when I'm trying use it in builder it spawning exceptions as soon as I'm selecting the element.

#

something about attributes overrides. it looks like if I'm using uxml asset in custom element constructor it still trying to use as a template instance if that makes sense.

it works as expected if I create the whole layout by hand in c# but I was just wondering if I can use builder for custom elements

hazy rivet
tulip sparrow
hazy rivet
still lantern
hazy rivet
#

Even merely deselecting everything does the above, too.

#

No custom inspectors. Custom components with serialised fields showing changing values every frame.

#

This is most significant with a small array of float4's showing their updates.

magic orbit
#

any clues?

hazy rivet
tulip sparrow
#

Does anyone remember the link to what the default style settings are for all the built in elements? Also, all of the default inherited styles?

still lantern
tulip sparrow
tulip sparrow
#

does anyone know if there a base field we can access yet that isn't abstract that I might be overlooking? Something like how TextElement is for text

#

better yet I guess, does anyone know how to manipulate a visual element to create a field?

faint yacht
#

How do i make non-interactable sliders in UI Toolkit? Like for the health bar.

#

I've didn't found any guides about the slider element in UI Toolkit actually

faint yacht
#

found this element, but not sure how to use it

#

when i try to declare it in .uxml like that

#

it doesn't seem to work

#

nvm, I've found out the ProgressBar element is probably not for the runtime

#

what could i use then, besides making a simple container, and overlaying it with something?

tulip sparrow
faint yacht
#

just thought there would be generic element for that

#

it's kinda easy to implement tho, so doesn't matter anyway

tulip sparrow
faint yacht
#

what patterns do you guys usually use to access data in classes tied to UIdocument gameobjects?

#

i'm pretty new to unity, and didn't found anything better than that

feral barn
#

How do you make UIElements PropertyField work with nested editors? We have EditorA that has PropertyFields, end EditorB that contains EditorA instances and shows them inline. For this we use CreateEditor to get EditorA's editor and add it to EditorB VisualElement, however the PropertyFields no longer display (while they work fine when we look at EditorA in the inspector). My guess is that when EditorA is displayed nested in another Editor, the PropertyField binding is borked and binds to the other Editor (so the properties are not found and nothing shows), but how do we fix this/avoid this without having to stop using PropertyFields and start using type-specific fields with manual binding ?

tulip sparrow
faint yacht
#

not sure how else could class hold a prefab

#

is it like found by tag and cached then?

tulip sparrow
#

for example

faint yacht
#

ooooh

#

this way

#

that looks just what i need, but does the editor actually hook up the UI

#

and show it before the game is started?

#

I've added up visual elements at runtime previously, and there was no other way to see style changes made to them besides starting the game

#

so I'm not really sure if it will work the same way, since you actually work with prefab in code

tulip sparrow
# faint yacht and show it before the game is started?

oh I think I get what you are asking, in a way yes. In the editor you don't need a UIGameObject. All Editor Windows comes with a rootVisualElement already. So, the way I design my UI is to try and be harmonious between both in game and editor. Basically, my "pattern" is the start all UI with a root element to make for easy grab create that root and it can be used with anything that is the root visual input

#

if that makes sense

#

this prefab is just for being able to display the UI

#

nothing more

#

for example even in it

#

I have a field set as public static VisualElement root;

#

for easier Query() access

#

a method called

    public void Initialize()
    {
        UIGameObjectCheck();
        uIDocument = uIGameObject.GetComponent<UIDocument>();
        Root();
        TestVisualElement testVisualElement = new TestVisualElement(root);
        //CreateCreateUserInterface();
    }
#

ignore some of the comments and naming

#

testing things all the time, so haven't removed/renamed stuff

#

then on my GameManager

    void Start()
    {
        userInterface.Initialize();
    }
faint yacht
#

well that makes sense, i'll try to implement something similar

tulip sparrow
#

You can even go further and remove the GetComponent by dragging and dropping the UIDocument reference. I just haven't cared to change it yet

#

ideally you would put a null check

drowsy nimbus
#

hey so is there any way to get antialising on uielements? i get these weird jadgginess when making my buttons with radial borders

tulip sparrow
drowsy nimbus
#

this is an editor window

tulip sparrow
#

and oh, let me see if there is someway to deal with that in UIBuilder

drowsy nimbus
#

i just found it out, tho it needs a bit of code

#

you can actually do this.SetAntiAliasing(4) and itll apply for levels of aa to the editor window

tulip sparrow
#

Do you guys know how to best overlap elements using relative? I only know if using bottom/left/right/top for positioning or using absolute

tulip sparrow
#

is there an enum or field or interface that makes a style become inherited down the chain? Maybe just make my own interface for this?

#

Just an example, I have a chain of visual elements that I have style.MinWidth = parent.style.MinWidth and just looking at saving some time

unborn bluff
#

if I calculate overlay screen space coordinates with a camera, will it work with UIToolkit and a position:absolute element with top sorting order?

var pos = cam.WorldToScreenPoint(transform.position);
tulip sparrow
unborn bluff
#

hmm, i have the element on top of the hierarchy

#

it's slightly off, but seems to do the trick:

            var pos = cam.WorldToScreenPoint(build.GetTransform().position + build.Config.HoverOffset);


            if (pos.z <= minDistanceToCam)
            {
                el.Hide();
            }
            else
            {
                el.Show();

                el.style.left = pos.x - (el.style.width.value.value/2);
                el.style.bottom = pos.y;
            }
unborn bluff
#

and does UIToolkit still work with TextMeshPro? doesn't seem like just specifying the ttf in USS works

rough scarab
#

It uses TextCore, which is text mesh pro's rendering engine. I believe you can also reference TMP fonts, but I think it's advised that you just create FontAssets. Create > Text > Font Asset

#

I'm not sure how that works in uss, I'd use the UIBuilder to reference it and see how it saves the USS

unborn bluff
#

ahaaaaaaaa thank you!!

tulip sparrow
#

under that same menu there seems to be a Text StyleSheet

#

I haven't delved that far yet hehe. I just use this UnityDefaultRuntimeTheme scriptableObject that I'm actually not entirely sure where it came from

trim vector
#

im having trouble importing ui toolkit/builder

#

when i install from git url, im getting missing assembly errors whenever i start the project, up until i edit/save a script within it upon which it then works.

#

yea whenever i change the script the missing assembly is in the errors vanish, but whenever i open the project i get missing assembly on UIDocument types, etc

#

any ideas?

tulip sparrow
# trim vector any ideas?

highly suggest migrating to newest version of Unity. if not, you need to lookup Assembly Definitions and do a lot of the figuring out yourself unfortunately

trim vector
#

thats dissapointing, i thought LTS projects would work with most packages

#

i will though, thank you

tulip sparrow
trim vector
#

yea that makes sense, my previous install was only 2020.3.18f1

#

which is from a month or two ago only

tulip sparrow
trim vector
#

oh so you are saying to not do an LTS post?

#

ive only ever done those, where might i find the current releases?

#

the alpha?

tulip sparrow
# trim vector oh so you are saying to not do an LTS post?

LTS is great, just as I've gotten deeper into understanding things it seems that is might be better to stay with the current release (idk about alpha, I don't delve into any alpha/beta things) and as your project gets larger / closer to finish transfer over to an LTS version since it's suppose to remain supported for a couple years

trim vector
#

hm yeah that makes sense

tulip sparrow
#

people say to only do this because it is apparently unfeasible to keep up with current update. I don't actually understand how that is so unless you coded things in a way that everything is tupled

#

but idk

trim vector
#

it just seems like the LTS version already outdated

#

ie it doesn't work with preview packages

tulip sparrow
#

I still haven't released anything... Hoping to soon β„’

tulip sparrow
trim vector
#

yea that makes sense, just dissapointing as a lot of the modern features are locked behind preview packages

#

like a style-sheet based ui

#

or ecs

#

both of which i want to develop using

tulip sparrow
#

but, that is where the transfering over to LTS when you want to publish is suggested, because then you should be able to open the project there, hopefully fix whatever is broken, then get a couple years of support out of it

trim vector
#

ohh yea that makes sense

#

so once you have resources/knowledge to do the custom assemblies/dependencies, that is when LTS is meant to be used

tulip sparrow
tulip sparrow
trim vector
#

for sure that makes sense thanks!

trim vector
faint yacht
#

Eh, so, how do i make a row that has a few squares in it (no matter the container aspect ratio) without using px unit?

#

Sorry if that question is stupid, kinda stuck on it for a while

tulip sparrow
#

turn on borders if you want to actually see it

#

or backgroundcolor

faint yacht
#

since % unit depends on container's width and height

tulip sparrow
#

then rotate flex directions

#

in each tier

#

flexGrow will automagically make them all equal... HOWEVER, until you put content into them

#

if you dont set anything else, content is larger would make things change without any other settings

#

but, you can fix that by using max numbers, or, turning off flexshrink, etc...

faint yacht
#

but not square-shaped

#

i'm trying to make that row of squares like they would be if their width and height were set in px

#

like that:

#

but that is I've set their width and height in pixels

#

and now i'm trying to get the same look with relative sizes

#

is it even possible to do in USS or i have to make the calculation and set their size in C#?

tulip sparrow
faint yacht
#

like will it still keep the squares square-shaped

tulip sparrow
faint yacht
#

but i want to give them relative size and still have them keep their square shape

tulip sparrow
#

however, this should be expected. It's not possible to make a square with those dimensions with this layout

faint yacht
#

css in the web however allows doing what I've told you with flexbox

#

that's why i was asking

tulip sparrow
faint yacht
#

that's the result i want exactly

#

yet i want their size to be responsive

#

and change with container size relatively

tulip sparrow
#

what you want it a square that maintains its aspect ratio?

faint yacht
#

yeah

#

there is aspect-ratio thing in YOGA layout

#

but it isn't supported in USS currently

#

as it seems

tulip sparrow
#

aspectRatio isn't a real flexbox style

#

IDK how in UIBuilder, I would have to check, but, simply limiting the mins/max will maintain a square

#

if you make it so a square can't ever be more than a square or less than a square basically

faint yacht
#

but i would have to make the min-max values absolute

#

like in pixels, right?

tulip sparrow
#

I think flexGrow auto takes care of those things though?

#

if you setup your containers properly I mean

#

this whole style of things is kinda confusing, like, how do I explain, IStyle has how many different fields? Yet, it is almost beneficial to never actually change multiple of those values within 1 element

#

like I've been working on a a base container for manipulating things which is like 32 elements right now just for the ease of adjustment, though, the saved element from it is as minimal as possible lol

faint yacht
#

well, i'd just better go and calculate the size for this squares based on container size in C#

#

xD

#

it doesn't really change in runtime anyway, i just want this to be flexible while i design it

#

and also work well with different screen resolutions

tulip sparrow
#

I'm still trying to figure out how to manipulate Relative position better. I find it SO easy to just use absolute, but, when I do that, I have to use callbacks more to manipulate other elements

faint yacht
#

Well i don't really remember who sent me the link to some post about aspect ratio

#

but thanks, it's actually helped me out quite well

#

Now i'm kinda wondering what's wrong with that border-radius here

#

it looks really edgy in runtime, and especially with some really big curves

#

is there a way to improve this besides using images instead?

#

and also what could i do about font sizes, cause they don't seem to adjust on different resolutions

tulip sparrow
faint yacht
tulip sparrow
# faint yacht i'd better use a picture instead at this point 😐

yeah haha. Also something you could do if looking to specifically do things inside code, is make a new texture and color the coordinates in that location. For example,

        int[] ints = new int[]
        {       // 00 01 02 03 04 05 06 07 08 09
            /*09*/ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
            /*08*/ 0, 2, 1, 1, 1, 1, 1, 1, 1, 2,
            /*07*/ 0, 0, 2, 1, 1, 1, 1, 1, 1, 2,
            /*06*/ 0, 0, 0, 2, 1, 1, 1, 1, 1, 2,
            /*05*/ 0, 0, 0, 0, 2, 1, 1, 1, 1, 2,
            /*04*/ 0, 0, 0, 0, 0, 2, 1, 1, 1, 2,
            /*03*/ 0, 0, 0, 0, 0, 0, 2, 1, 1, 2,
            /*02*/ 0, 0, 0, 0, 0, 0, 0, 2, 1, 2,
            /*01*/ 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
            /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 2
        };

is just how I setup a 10 x 10 texture in code

#

0 is no color, 1 for black end, 2 for white end

faint yacht
#

yeah i got it

tulip sparrow
#

Is the point of IStyle.translate and IStyle.scale etc to eventually deprecate IStyle.transform and the transform methods on base visual element? Or, just another option, or? Just something I've been wondering. I've been using all transform modifications inside of IStyle since upgrading versions rather than the others

tulip sparrow
#

I notice in a lot of CSS docs that they include the displaystyle in the root element. We only need to mention the display style if we want the element to be invisible and absent from layout right?

tulip sparrow
#

are any of you familiar with IStyle.transformOrigin? I'm trying to figure out how to best handle not letting someone drag a window to larger than the game screen for example, but, having things like shrink on doesn't seem to counteract changes done through translate

still lantern
tulip sparrow
still lantern
tulip sparrow
#

but I don't know because I haven't done anything with it yet hehe

still lantern
tulip sparrow
still lantern
slender token
#

Looks like currently TextField fires **ChangeEvent **on every character while I'm editing. Is there a way to change this behavior to commit changes only when I hit Enter or lost focus? Sometimes changes on every character can be very annoying and actually it applies to numeric fields as well. Like if I'm typing 1234 in integer field I probably don't want to use callback four times for 1 12 123 and 1234

Or in that case I should implement custom handling between FocusInEvent and FocusOutEvent?

static canyon
slender token
#

that's exactly it, thank you!
should have properly read the docs

static canyon
rough scarab
#

UI Toolkit: Added UI Toolkit implementation for UnityEvent drawer and LazyLoadReference drawer.

UI Toolkit: Added UI Toolkit implementation of MinMaxGradient drawer.

UI Toolkit: New vector drawing API added to VisualElements.

UI Toolkit: The InputField is now driven by TextCore.
All TextCore text assets (FontAsset, Text Settings...) now work in InputFields.
We have added an inner ScrollView to InputFields.
All TextElements including Labels are now selectable.

#

UI Toolkit: Added: MultiColumnListView control in UI Toolkit.

UI Toolkit: Added: MultiColumnTreeView control in UI Toolkit.

UI Toolkit: Added: TreeView to the public UI Toolkit API.

UI Toolkit: Added: View controllers used for ListView and TreeView are now public and can be inherited from for more control.

faint yacht
#

How could i style Slider element in USS? It's kinda hard to figure out by docs, I've only found some C# properties of it.

tulip sparrow
# faint yacht How could i style Slider element in USS? It's kinda hard to figure out by docs, ...

Some of these native visual elements unfortunately don't offer A LOT of a breakdown yet. You have to use the visual element methods to figure out the nested things in them. For example, a text field has a nested visual element called unity-text-input which you can modify through the UIToolkit API, but, can't inherit from or make an instance of. I'm assuming the slider does the same. Alternatively, you make your own visualElement or Image VisualElement or something and just make your own slider

#

if you are curious on how to make your own, what I would do is, 1 visual element to be the main container, a child text element for a label, a child visual element for the line texture, a child visual element of the line child as the image

#

then, either register callbacks on the image visual element to decrease/increase, or, and technically better, make that child element inherit from its own visual element, and alter the default actions of it

raw flicker
#

Hello guys, so I have one question. How can I like get a debug.log message when someone pressed the determined "cancel" button on UI? Because I set up a join menu and I want the player to reset his actions by simply pressing "b" on controller or any button. I dont really seem to find anything.. im kinda new to this. Thanks for any help

tulip sparrow
#

I just realized it wasn't as hard to make a custom input field as I thought it would be. For some reason I kept thinking an input field was different. Just made it so when I click on the field, I can edit a TextElement, or clicking to make a checkmark visible or not

tulip sparrow
#

does anyone know if registering callbacks to be called from a visual elements default actions are also better performance than registering to the callback directly?

tulip sparrow
#

so I have been creating textures for different cursors and applying them through the style.cursor, but it made me wonder, what is the difference between doing them this way and just doing it through setcursor?

tulip sparrow
#

is doing something like this like

        VisualElement colorContainer = new VisualElement();
        rContainer.Add(colorContainer);
        colorContainer.style.flexDirection = FlexDirection.Row;
        colorContainer.style.height = 10;
        for (int i = 0; i < 100; i++)
        {
            VisualElement colorElement = new VisualElement();
            colorContainer.Add(colorElement);
            colorElement.style.backgroundColor = new Color(i * 0.01f, 0, 0);
            colorElement.style.width = 1;
        }

much more taxing than just doing 1 lets say, 100 x 10 texture?

static canyon
#

Side note: Unity will probably release a runtime color picker at some point in the near future. So will I πŸ˜†. Unity one will probably be 2022 only I would guess.

shell pivot
#

hi how can i change unity input field box to rounded corners?

tulip sparrow
still lantern
#

Also happy to see the multi column views added. I think all that is missing now is some form of grid view. After that UITK is capable by default of doing everything IMGUI can.

tulip sparrow
#

They need to make some of their inner workings of some of the controls more accessible. For example, basic functionality of some things don't necessarily need the overhead that comes with creating something like a Slider through Unitys provided Slider, yet, is easier to just use than creating your own visual element if you don't know what to do

#

things, like I would personally propose, as an example, would be the polymorphism from UIElements.BindableElement not even exist, and rather the IBindable interface expanded

still lantern
#

Making custom controls is not some black art. It is a core part of using and extending UITK.

tulip sparrow
# still lantern I disagree, if you need something that simple, then just create it on your own. ...

the ease of use isn't my concern. The things they have created are great! What I'm simply stating is that if someone was using UIToolkit and didn't have any experience in the visual element design, I would love it to be easier to access some of the inner workings of some of the elements they have made. The bindablelement comment was more based on the idea that I think certain polymorphism can lead to sloppiness

tulip sparrow
# still lantern Ah, I see.

basically, it doesn't make sense to me that something like BindableElement exists and is easily accessible, but, for example, InputField is internal, or private nested within something

#

but, I know we can also just use reflection hehe. Just try not to first

#

I could also do what you suggested and actually try and give feedback instead of hoping they read here... lol

still lantern
still lantern
tulip sparrow
raw flicker
#

Hello guys, so I have one question. How can I like get a debug.log message when someone pressed the determined "cancel" button on UI? Because I set up a join menu and I want the player to reset his actions by simply pressing "b" on controller or any button. I dont really seem to find anything.. im kinda new to this. Thanks for any help

still lantern
still lantern
raw flicker
#

oh okay thanks

dusty mantle
#

Hey!
I'm trying to use USS custom properties to change the value from C#, is that possible?

#

I did not see anything like that in the docs, but maybe I did not find at the right place?

#

Another question: can we create a vector image on the fly to use it instead of drawing via MeshGenerationContext? I hope getting better rendering since Vector rendering is now clean, but not the MeshGenerationContext one

tulip sparrow
tulip sparrow
#

like what are you trying to do

dusty mantle
dusty mantle
# tulip sparrow I'm not sure 100% on what this question is asking?

I want to draw some arcs so I'm doing that via the GenerateVisualContent method, but this does not supports anti aliasing ; recently AA has been added to Vector elements, so I'm wondering if I can create some Vector element at runtime (like I can write SVG via JavaScript in a Web Page), then apply it to any VisualElement or Image

tulip sparrow
dusty mantle
#

But, I want to use custom properties to get the value on many style values instead of defining them manually ^^

tulip sparrow
still lantern
#

But that doesn't make sense... hmm, you can try looking at the UIBuilder source code to see how it does it.

dusty mantle
#

custom properties are not variables

still lantern
dusty mantle
#

only a getter :/ no setter

still lantern
#

Yeah :/

dusty mantle
#

yes, I do that all the time, so USS and UXML are useless most of the time... I'm a Web developer and I'm sad about that

still lantern
#

@dusty mantle Ah found it.

#

Apparently you need to register to the CustomStyleResolvedEvent

dusty mantle
#

I'm mostly doing C# to build thing that I should be able to do with UXML/USS but, there are some things that are not available without C# making me going back to C# all the time ^^'

dusty mantle
#

Ah thanks πŸ˜„

dusty mantle
#

Ok so I can get USS custom properties values in C#, but cannot send them?

#

@tulip sparrow already read that without founding what I want :/

still lantern
tulip sparrow
still lantern
#

I guess it is odd you can't set it

tulip sparrow
#

just going to toss out some random links

#

for a few secs

#

see if any of them you havent already checked out

dusty mantle
#

I think this is not possible for now, or not documented for now

still lantern
dusty mantle
#

@tulip sparrow I've already check all of links you have sent ^^'

dusty mantle
#

And for the Vector thing, I'm doing something like that, and for now it's a lot of pixels ^^' :

leaden coral
#

Hello did anyone manage to have drag and drop on the new UI builder package ?

tulip sparrow
#

I've been trying to learn more about interfaces using UIToolkit. I'm trying to create one and could use a little help if possible. Is it possible to force the use of protected override void ExecuteDefaultAction(EventBase evt) from an interface, but, also, force it to include the correct event to check for?

#

I guess I could just make a function that has to be used if you use the interface, then make that called from the visual elements override execute?

#

this is what I'm trying to implement

public interface ICursor
{
    UnityEngine.UIElements.Cursor hoverCursor {get; set;}
    UnityEngine.UIElements.Cursor selectedCursor {get; set;}
}
#

rather, rename that to the hovercursor

lofty frost
#

Serious question:
is there an easy way to force an VisualElement in the shape of a square?
(Without setting absolute height and width values)

Some easy pure css hacks do not work, due to the lack of pseudo classes

tulip sparrow
#

I'm not sure if the box visual element they have is default a box

#

but if it is, they went through the exact process you would need to make it a box also

tulip sparrow
lofty frost
#

Hmn damn, i really hoped you'd say "sure, there is a checkbox for that" or something similar πŸ˜„

So your idea is really to add a transparent child image with a square texture to the element and then take those values?
I'd never come up with such an idea, and i'm trying to get a square for 3 hours now πŸ˜„

tulip sparrow
lofty frost
#

ooooooh.. i might be able to put my image into the checkbox instead of any "check mark" content

#

That might be a brilliant idea!

tulip sparrow
#

and make it perma a square size

lofty frost
#

Thank you for your input πŸ™‚
I do now have hope again, that i'll be able to make it πŸ˜„

faint yacht
#

like that, works well most of the time

#

then in the contents of this visual element you do that:

#

to get the child positioned exactly in the left-top corner of the parent, avoiding it's padding with position: absolute

#

that worked well for me cause i've needed to put an image as a child of this square box

#

so left-top corner works just right

#

also is it right idea to make all the UI components in C# using UXML-factory and then compose them in UXML?

#

like the way we do it in web with React basically

#

may it have any issues?

#

I've didn't tried yet

tulip sparrow
#

it's just styled under the UXML banner essentially

faint yacht
#

i mean, i do understand the concept

#

but what's the answer to my question?

tulip sparrow
faint yacht
#

but is it right way to do the job?

#

like making all the UI elements in C#, and not hacking around UQuery and simple VisualElement in UXML

#

for example, currently I'm just usually using Query to get the button and add behaviour on it

#

but what I'm planning to do is to make my own button that has the behaviour in it, and just use it in UXML composing the elements

tulip sparrow
# faint yacht but is it right way to do the job?

if I were to base it off of the UIBuilder tutorial, yes? However, strictly speaking, I think there is some differences if you desired it to be primarily be from UXML or from C#. So, if you make something for UXML you should include more of the initialization within the UXML Factory, if C# outside of the factory. That being said, I haven't messed much with UXML Factory yet, so I don't know for sure. I have been including it at all the end of my scripts, but, not actually sure if its correct

tulip sparrow
#

like let me see if I can find it again

#

there is class names and stuff of things that looked to exist inside the factory, but not documentation really on yet, so I was kinda looking I think at what you are trying to do to utilize the factory

#

doesn't generate visual elements, but visual elements use it to generate schemas

tulip sparrow
# faint yacht but what I'm planning to do is to make my own button that has the behaviour in i...

oh yeah, thats what I saw that might help. If you go under window and check out UI Toolkit they have samples on the C# for example

// Action to perform when button is pressed.
// Toggles the text on all buttons in 'container'.
Action action = () =>
{
    container.Query<Button>().ForEach((button) =>
    {
        button.text = button.text.EndsWith("Button") ? "Button (Clicked)" : "Button";
    });
};

// Get a reference to the Button from UXML and assign it its action.
var uxmlButton = container.Q<Button>("the-uxml-button");
uxmlButton.RegisterCallback<MouseUpEvent>((evt) => action());

// Create a new Button with an action and give it a style class.
var csharpButton = new Button(action) { text = "C# Button" };
csharpButton.AddToClassList("some-styled-button");
container.Add(csharpButton);
faint yacht
tulip sparrow
faint yacht
#

it's not really acceptable cause i can't see my UI changing in hot reload basically

#

that's why I'm planning to mess with making my own classes with UXML factory that is exposed to UXML

#

so i can compose them in UXML before the runtime

tulip sparrow
faint yacht
#

i know how to do that

#

the question was if it is best practice for most cases or not basically

tulip sparrow
#

so I do that

#

and it works fine

tulip sparrow
#

is panel the best way to reference the topmost visual element to make a popup appear above all other elements?

#

in runtime I have the root visual element to be referenced from anything, but, was wondering other routes

#

nvm, panel.visualTree.Add(colorPicker); worked perfect

#

I think I read somewhere that changing visibility completely redraws the element, so, using display = Display.None is atm better? Is that still true?

#

or do I have it backwards? Or

tulip sparrow
#

turns out Unity's panels don't actually have any useful settings already for font. Does anyone know of an easy way to do with font styling? Maybe I need to start learning that stuff idk. Has to be an easier way than if (colorPicker.parent != panel.visualTree.ElementAt(0)) panel.visualTree.ElementAt(0).Add(colorPicker);

#

mind you, I'm trying to stay within runtime standards so that I can use this at runtime also, so, trying not to use any editor useful things

tulip sparrow
#

this is for UIToolkit

unborn bluff
#

I didn't know what channel to post in, sorry.

tulip sparrow
unborn bluff
#

haha

tulip sparrow
#

okay, I think I'm just going to settle with

    public static VisualElement RootVisualElement(this VisualElement visualElement)
    {
        if (visualElement.parent != visualElement.panel.visualTree) return RootVisualElement(visualElement.parent);
        return visualElement;
    }

for now

#

now my static visual elements can have a home even if I don't know the root

#

but to be in front of everything

tulip sparrow
#

what am I doing wrong? If I have a container that is 500x500, and 2 containers inside with 1s minwidth to be the width of a 256 width texture, how come that container falls about roughly 30px short

tulip sparrow
#

if I inherit from VisualElement, and IStyle, can I override what a style does?

#

I guess I can just do public new IStyle style;

#

oh okay, I think I'm understanding interfaces a little better? Can just do something like

public interface ICustomStyle : IStyle
{
    int TestInt {get; set;}
}

which will add to the IStyle interface basically? I know I have to do similar with the resolved side also?

still lantern
#

There is no way to add properties to a class or interface.

tulip sparrow
#

for example

#

for example

still lantern
tulip sparrow
still lantern
tulip sparrow
#

it means I can extend functionality without clutter

#

since extension methods cannot override

still lantern
tulip sparrow
#

one reason I thought this was interesting is it lead me to do

    public new void ExecuteDefaultAction(EventBase evt)
    {
        base.ExecuteDefaultAction(evt);
    }

from a base public class CustomVisualElement : VisualElement which actually was quite nice. I've been spending a lot of time in this UIToolkit, and, I find there to be a lot of "clutter", so, I was looking into removing inheriting from visualelement while still having basically all the functionality of a visualelement if I wanted it

#

also, something I didn't realize till now, is being able to make protected internals public without reflection

still lantern
tulip sparrow
tulip sparrow
# still lantern To do what...?

idk, just something I didn't realize you could do. I've never really thought about inheriting from something and using that object as like a container that stuff from the outside can access

#

like in the case of the defaultaction based off what you said might be better to not do new and just make a different function that can still use ExecuteDefaultAction

tulip sparrow
#

is there a native callback you can register to for style fields specifically? Can't seem to figure out how to. I was assuming you use normal RegisterCallback if you aren't using the INotifyValueChange<T> interface

tulip sparrow
#

do all position checks happen from the top left corner? Or does align and justify change those also

plain folio
tulip sparrow
#

I'm confused by some of these structs, why is there StyleTranslate and Translate? I've been dealing with it because that is how it is, but, just something I've been wondering

tulip sparrow
# plain folio hey, what are the possible reasons that a DropdownField cannot be clicked to exp...

I can't say for sure based off this, but, when using clicking events there is different things that must be checked, for example, PointerEnterEvent is for a VisualElement AND its descendants, while, PointerOverEvent is for a VisualElement explicitly. Make sure to check you don't have an overlay or something that is receiving priority. Second is focusable you can click on something, and it receive priority from input events, but, if it is the only element there that can be focused, you can still make it receive input events, such as, spacebar, while not actually being the main target of the pointer events

#

Also, consider using pointer capture and release as it will force a pointer to receive all incoming pointer events while captured

#

can only have 1 capture at a time, and a new one will overwrite the previous

plain folio
plain folio
tulip sparrow
#

how do you use TextElement.MeasureTextSize when some of its params are why you are using it...

tulip sparrow
#

I'm trying to make a close container that has options between Remove IStyle.display and IStyle.visiblity, but want to make sure I actually have them correct for what they do. ``IStyle.displayleads me to believe thatIStyle.visiblityalso removes the element from the hierarchy, so, is it doing whatRemove` does?

tulip sparrow
#

is there some sort of significant benefit over using the Image control vs just using my own that just alters style.backgroundImage?

sacred escarp
#

I'm add a com.unity.ui in package manager for UIToolkit, but there are some error that spawn like that. So what should I do?

keen mulch
#

y are my buttons not working?

tulip sparrow
plain folio
#

but how do I check whether pointer is currently over the UI without an EventSystem on the scene?

tulip sparrow
#

how do I flex equally? Regardless of content, flexGrow = 1 flexShrink = 0? Doesn't seem to be equal, do I need to set the basis also?

#

on yoga playground doing it this way with no basis makes it equal, but, in actual runtime it doesn't, but I can't put similar content in the playground that I do in unity hehe

tulip sparrow
#

I need a good name for my forced width/height. Do you call that absolute?

still lantern
#

I mean, yes that would be the name I guess.

tulip sparrow
still lantern
#

min/max is used along with the normal flex sizing

tulip sparrow
#

trying to think about best way to go about forcing an element to be a certain width/height no matter what

still lantern
#

To set the element to be a specific size.

tulip sparrow
still lantern
tulip sparrow
still lantern
tulip sparrow
# still lantern ?

The following properties are inherited:

color
font-size
unity-font
unity-font-style
unity-text-align
visibility
whitespace

#

on that page

plain folio
#

how to add layout code (uxml) to a custom VisualElement?

tulip sparrow
#

how do I get a strings length at runtime? I'm not quite understanding the domeasure

dense scaffold
#

I've been using UIToolkit off and on for two years or so, but now I've hit a strange problem: images are always rendered downscaled by Unity whenever placed inside a custom inspector. Has anyone encountered anything like this ? (and hopefully: found a fix?)

leaden coral
#

Hello, do you attach all scripts that update UI elements (i.e label value) to the game object that contains the UI document ?

#

Or Is it good practice to have multiple UI documents in your scene ?

dense scaffold
#

"document"?

dense scaffold
dense scaffold
tulip sparrow
# dense scaffold By definition, flex-grow gives all items an equal share .... if you want them to...

ty for the responses! I'm trying to better use relative containers so that I can make more premade UIElements, out of frustration when I can't seem to figure out something yet through the yogalayout playground I just make it absolute, which honestly isn't that bad, I just end up having to make more changes through the GeometryChangeEvent. Do you know if there is any of the interfaces you can read data changes from before the next frame? Maybe have to use ImmediateElement?

plain folio
#

hey it seems that Dropdowns dont work on mobile platforms by default - any way to fix it?

tulip sparrow
plain folio
#

thanks, ill try it out

tulip sparrow
# plain folio thanks, ill try it out

It's worth checking out the default execution that already exists on UIElements. Depending on how you have your ui setup, something else could be capturing the mouse events

plain folio
#

hm its already registering PointerDownEvent

#

in an empty project it's not working either

tulip sparrow
#

only one thing can capture the pointer at a time, but, it's the most recent to capture and capturing always overwrites the previous one

#

also, make sure you don't have an absolute container covering the UIElement that doesn't have picking disabled

plain folio
#

btw do I need to add Panel Event Handler to gameObjects with UI Document?

#

or panel raycaster

#

or do I need to have an event system in the scene?

tulip sparrow
plain folio
#

Im using 2022.1.0a16

#

and the dropdown is populated

#

on pc working perfectly fine

#

on android its showing that it's focused but not opening

tulip sparrow
plain folio
#

πŸ€” maybe mousedown and pointerdown are colliding so one is opening the popup and the other is closing it?

tulip sparrow
#

so you need to either create one yourself, or, use one of unities

#

which could be part of your problem

#

the UIDocument doesn't default render text

plain folio
#

i have DefaultRuntimeTheme

tulip sparrow
#

oh okay, that is good to know. Sorry, just trying to go through all steps possible

plain folio
#

yeah no problem

#

was it ever working on mobile for you?

tulip sparrow
#

so everything usually always works hehe

plain folio
tulip sparrow
plain folio
#

maybe maybe

#

just wondering what could be the source of this issue

tulip sparrow
plain folio
#

good to know

tulip sparrow
#

so, if you could be technically canceling your mouse event if your do something with the pointerevent right after

plain folio
#

its receiving pointer down, mouse down & click at the same time

#

but weird that it works on pc

tulip sparrow
plain folio
#

yeah sure

tulip sparrow
plain folio
#

maybe the if statement at the top is breaking something?

plain folio
plain folio
tulip sparrow
#

You have populated the dropdown correct?

plain folio
#

yeah

leaden coral
#

Hello for updating UI values in runtime , should I use binding or regular .Q<label>.text in my code ?

tulip sparrow
# plain folio

let me see if I can get my phone setup with the unity remote

tulip sparrow
plain folio
tulip sparrow
plain folio
#

i dont know exactly but i suspect it can process events differently

#

uhh ShowMenu() is private so I cannot open it manually :/

plain folio
#

@tulip sparrow found the problem

tulip sparrow
plain folio
#

but...

#

no idea how to fix it xD

tulip sparrow
plain folio
#

yeah everything is working fine except it checks if the pointer location is inside visualElement

#

and it returns false only on mobile

tulip sparrow
plain folio
#

ohh okay

#

how to check it?

tulip sparrow
#

uhh with code, I know you can do a hasPointerCapture check

#

IDK which, if any any, of unitys visual elements them made default captures

#

but, I personally use capture anytime I'm dealing with pointer/mouse events

plain folio
#

you mean this?

tulip sparrow
#

yeah, that checks, to actually capture you use CaptureMouse() or CapturePointer(PointerID) and then the releases

#

for example, I do something like

    protected override void ExecuteDefaultAction(EventBase evt)
    {
        if (evt.eventTypeId == PointerDownEvent.TypeId())
        {
            this.CapturePointer(PointerId.mousePointerId);
            pointerPosition = evt.originalMousePosition;
        }
        if (evt.eventTypeId == PointerUpEvent.TypeId())
        {
            this.ReleasePointer(PointerId.mousePointerId);
        }
        if (this.HasPointerCapture(PointerId.mousePointerId))
        {
            if (evt.eventTypeId == PointerMoveEvent.TypeId())
            {
plain folio
#

so on pc it isnt captured

#

(d is the dropdown and vi is the visualInput)

#

lemme check on android

tulip sparrow
# plain folio so on pc it isnt captured

you don't need to capture, so I don't think the defaults have capture, I'm saying I capture in complex situations as to force mouse events to be sent only to that visual element while captured, and so my capture question was mostly towards do you have something else capturing preventing the dropdown from receiving events

plain folio
#

oh okay, so no, its just an empty project

#

with one uidocument

#

that contains a simple dropdown

#

just to test it in default circumstances

tulip sparrow
plain folio
#

you actually helped me quite a lot haha

#

maybe i can just copy the unity's code of dropdown and remove the containsPoint check

tulip sparrow
#

I had a similar problem with elements not showing up randomly in scroll view for example, so I built my own haha

plain folio
#

cuz im too lazy to create a custom dropdown

tulip sparrow
# plain folio cuz im too lazy to create a custom dropdown

to save your time I personally found in visualElements is inherit from the specific things you want to alter, and then build down, so, for example, inherit from dropdown, and take advantage of the overrides and stuff till you want to make a more complex dropdown menu possibly

#

the cool part about doing this also is you kinda already create a container for that visual element, some might consider it excessive, but, I love making a separate container for basically every single visual element

plain folio
#

btw how do you check if the pointer is over any ui document?

#

like EventSystem.current.IsPointerOverGameObject

tulip sparrow
# plain folio btw how do you check if the pointer is over any ui document?

that I'm not sure of, I think you just in a visual elements OnOver do something like ((VisualElement)evt.target).panel to confirm the panel, but, I haven't done multiple UIDocuments yet, so not sure. I just have one UIDocument and make it the size of my screen like the older canvas, and just essentially make root visual elements within that rootvisualelement

plain folio
#

hmm

#

im trying to do

#

but unfortunately it doesnt work for some reason

tulip sparrow
#

how come some styles not defined seems to apply the the auto stylekeyword though it isn't defined, and others dont, and where do I find all the automatic style values that might be set

#

also, how come something like flexDirection is automated, yet, isn't checked as inherited, so, if you were to do something on the next child element of that element assuming the flexDirection, you have to go back and actually set the flexDirection though it could already be doing a flex in that direction

leaden coral
#

Hello, what is the best approach to instantiate a visual elements and its children at runtime ?

gray lark
#

Hi. How can I change the value of a PropertyField without triggering a notify?

tulip sparrow
gray lark
gray lark
tulip sparrow
#

was more of the link

#

At least I think? I haven't checked if that is internal

reef needle
#

My game is in 240p. UI text looks dreadful. The left is textmesh pro and the right is standard UI text. Is there a way of making this look less terrible, maybe by removing filtering?

umbral zodiac
tulip sparrow
#

Just to make sure, there is no reason I need to if check style.display = DisplayStyle.None on a uielement that I have do something "on open". I just have style.display = DisplayStyle.Flex and style.display = DisplayStyle.None; in the close

#

like, there is no reason it would set it twice and cause some sort of issues?

unborn bluff
#

Say I want to have a settings menu appear as a pop-up over the main menu. Is it possible to do this without duplicating the main menu, switching between the two, and maintaining both?

tulip sparrow
#

basically will go to the first visual element in the panel, you could go as far back to the panel if you want, but, Unitys default editor panels for some reason don't have any things attached to them for text etc..

#

I guess note that that isn't a big deal if you implement your own custom fonts, but, since I'm doing things based off Unitys default things and those are naturally inherited, it was for me

unborn bluff
#

Maybe I'm missing something, but isn't that just visualElement.panel.visualTree.children[0] but potentially with lots of extra steps?

tulip sparrow
tulip sparrow
#

it was to make sure that I was at the top of the root for that specific thing without accidentally being in a different branch of elements

#

so, if you have multiple branches from the panel, it may not always be in [0] or [1] etc..

unborn bluff
#

Ah

tulip sparrow
#

so, for example, this color picker I'm working on, I want it to popup in front of everything in that hierarchy, but, not everything completely

#

so I use this, then send it to the front, and make it absolute

tulip sparrow
# unborn bluff Ah

side note, this was because of editor things that were annoying me. At runtime my UIDocument field is static and accessible from my game manager

#

so I don't use this there

dense scaffold
#

Has anyone got working code for reading the width of the Inspector window? (NB: there's a Unity API method for it, but it's broken in all versions less than 2021. I need 2020 absolute minimum, and realistically something that wokrs in 2019)

craggy latch
#

Hey! I can't seem to figure out how to swap a background image for anther sprite of a VisualElement (since that is what I have dragged in the Ui builder). I found that I can access the "Background" struct by calling GetFirstOfType<VisualElement>().style.backgroundImage.value but I can't seem to find a way to set the sprite to something else. I would really appreciate some help with this πŸ™‚

dense scaffold
#

backgroundImage is a struct. Your IDE should be telling you that you cannot set a value on that directly and should auto-fix this for you if you try (if not: get a better IDE). The code will be something like: ....style.backgroundImage = new StyleBackground() { value = { texture = blah}};

#

(you need a Texture2D reference first, use any of the Unity methods for loading a sprite in C#)

dense trout
rough scarab
dense scaffold
#

I'd say it's a long way short of being ready for runtime. A few brave souls are using it for that, but there's many gotchas.

#

That said ... it works fine for basic usage.

dense trout
#

Yeah, seems to depend on which page I look at in the docs as to whether it's "recommended" or "intended to be recommended".
It's a bit of a joke to have something that came out 3 years ago and still isn't finished. Not sure what I expected though.

#

Thanks for the advice though - saves me a bit of grief. πŸ˜„

lofty frost
#

Well i'm trying to implement a runtime UI in my Game using the ui-toolkit.
It's a bit of a pain. The amount of infos and quality of documentation is painful πŸ˜„

But all in all it works ^^

leaden coral
#

Hello, is there a way to view the hierarchy of a visual element in runtime ?

static canyon
#

or UIElements Debugger in 2019

leaden coral
tulip sparrow
#

when I do something like

            accessor.RootVisualElement().Add(instance);
            instance.style.display = DisplayStyle.Flex;

Is there a reason I should make sure the displaystyle is flex before setting its parent?

tulip sparrow
#

does unitys default dropdown field have a way to already detect changes? I just hope i'm not doubling down on doing

            dropdownField.RegisterValueChangedCallback(OnChangeEvent);
        }

        DropdownField dropdownField;

        void OnChangeEvent(ChangeEvent<string> e)
        {
            Debug.Log("Test");
        }
craggy swift
#

So this is a game runtime question. I am creating a resizable draggable window control (Popup Window, MDI Window, Floating Window - think floating inventory window that you can drag and resize). Things work except if I move too fast I move outside the control and no longer get events. Is there a way to register global mouse callbacks in the ui toolkit? Or is there some other approach I should be looking at? Unity: 2022.1.0b2

craggy swift
craggy swift
#

Are there any examples using the MuliColumnTreeView or MultiColumnListView somewhere?

thin swift
#

My Editor window does not match up with the UI Builder whatsoever, does anyone know what the issue is?

#
public void CreateGUI()
    {
        // Each editor window contains a root VisualElement object
        VisualElement root = rootVisualElement;

        // Import UXML
        var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Game/Inventory/Editor/ItemSheetEditor.uxml");
        VisualElement labelFromUXML = visualTree.Instantiate();
        root.Add(labelFromUXML);
    }
weak fog
#

Can I use binding-path of a Button to bind it to a method? If so what format do I need to specify?

leaden coral
weak fog
gusty estuary
#

Hey guys. Any idea what UI is included in 2019 version of Unity?
I want to make a UI mod for game that is already based on IMGUI, but I don't want to use it. I want to use some other UI system instead.

#

I don't have any access to editor in this case, I only have scripting options.

fallow anchor
#

Anyone else have the issue that the UI builder preview does not match the runtime ui?

#

It seems like labels take more space for some reason

#

Left is the UI builder preview, right is the runtime UI

#

The thing that seems to be massively different is the spacing between two vertically aligned labels ("dexterity" and "10"). On the right, the strength and 10 are 1 label with a \n in the text, and the dexterity are two labels. I'm not sure why the spacing is so massively different in the preview and runtime. All margins and padding is at 0

distant oracle
#

Is there a way to disable horizontal scrolling on a scrollview? I want a scrollview that can only scroll vertically.

umbral sonnet
#

Hello, it is possible to place elements to static place in scene? (Like UI elements in Canvas world space) Thank you! πŸ™‚