#Make a mod with a UITK GUI

1 messages ยท Page 4 of 1

marble shale
#

Is this OK?

dusty berry
#

    "com.unity.addressables": {
      "version": "1.18.19",
      "depth": 0,
      "source": "registry",
      "dependencies": {
        "com.unity.scriptablebuildpipeline": "1.19.2",
        "com.unity.modules.assetbundle": "1.0.0",
        "com.unity.modules.imageconversion": "1.0.0",
        "com.unity.modules.jsonserialize": "1.0.0",
        "com.unity.modules.unitywebrequest": "1.0.0",
        "com.unity.modules.unitywebrequestassetbundle": "1.0.0"
      },
      "url": "https://packages.unity.com"
    },
#

this is how ti works

marble shale
#

Cause this isn't

dusty berry
marble shale
#

How do you re open that?

dusty berry
#

right click on the tab, up top

#

close

marble shale
#

nvm, double click uxml

dusty berry
#

re-open is window

#

or that

marble shale
#

Except that gives the same fubar result

dusty berry
#

for future reference is Window>UITK iirc

#

Oh thats wierd

#

do you have errors on the console?

#

your uxml might be faulty

marble shale
#

Yes, the same as before

dusty berry
#

try smth

#

a sec let me get the id

shadow tree
#

it already is

marble shale
#

Touched some of the code, closed and reopened, but still get the damn dialog warning me

shadow tree
marble shale
#

Now have the UI Builder back up though

dusty berry
#

just click on it, copy and paste

marble shale
#

I found the check box to toggle the full log, but see nothing I'm able to click on to copy/paste.

#

May have found it?

#

Hey, I need to scoot. I'll check back later. No real losses here as I still have the old project.

dusty berry
#

that was not it unfortunatelly, but ok! i hope that we have a fix for this soon :D

marble shale
dusty berry
#

go for it!

#

tho i think it will be a ton of unity stuff

#

that we wont make sense of xD

marble shale
#

One diff is that the old project has a UI Toolkit folder and the new one doesn't. Am I maybe missing that or is it not necessary?

dusty berry
#

HOW

#

well that would explain a lot

#

wheres that UI Toolkit folder located?

marble shale
#

Under Assets

#

in the old project MNC_UI

dusty berry
#

what does it contain?

marble shale
#

The new one is deceptively named MNC-UI

dusty berry
#

ah

#

yes, the elevated MNC ui

marble shale
dusty berry
#

couldnt be that

#

can you send me the whole log line?

#

if you go onto the unity's console

#

and click on the error line

#

it will show below a selectable text

shadow tree
#

The UI Toolkit folder gets created automatically if you add a UI Document object to the scene

marble shale
#

Then why don't I have one?

shadow tree
#

Well have you added a UI Document object to the scene?

#

And it should work without it, because the only stuff it contains is PanelSettings and related stuff, and those shouldn't be used anyway, the ones in the UitkForKsp2 package should be used

#

I'm pretty sure I was building AppBar assets fine without the folder

#

It shouldn't have anything to do with Unity not being able to find some classes, since it doesn't contain any code, just some default auto-created assets that we don't need

#

I mean sure, you can try it

#

But I'd be really surprised if it was the root cause of the issue

marble shale
dusty berry
#

any of them

#

they probably point all to the same file

marble shale
#

Here's one: Library\PackageCache\uitkforksp2.controls@d8cc3fd6bc\Runtime\ExposedControls.cs(57,26): error CS0311: The type 'UitkForKsp2.Controls.RadioButtonGroupControl.UxmlTraits' cannot be used as type parameter 'TTraits' in the generic type or method 'UxmlFactory<TCreatedType, TTraits>'. There is no implicit reference conversion from 'UitkForKsp2.Controls.RadioButtonGroupControl.UxmlTraits' to 'UnityEngine.UIElements.UxmlTraits'.

dusty berry
#

Theres no conversion from the same type AsukaDead

marble shale
#

Here's another Library\PackageCache\uitkforksp2.controls@d8cc3fd6bc\Runtime\ExposedControls.cs(9,26): error CS0311: The type 'UitkForKsp2.Controls.Dropdown' cannot be used as type parameter 'TCreatedType' in the generic type or method 'UxmlFactory<TCreatedType, TTraits>'. There is no implicit reference conversion from 'UitkForKsp2.Controls.Dropdown' to 'UnityEngine.UIElements.VisualElement'.

dusty berry
#

go to that PachageCache folder

#

and delete theuitkforksp2.controls folder

marble shale
#

OK done. close and reload?

dusty berry
#

yup!

#

it will redownload it

#

if that doesnt work

#

just remove the package and i'll send you the file, will work too

marble shale
#

Same warning

#

Same errors

dusty berry
#

thats ok

#

ignore

marble shale
#

Also I got this this time

#

Probably doesn't matter...

dusty berry
#

thats

#

very interesting

#

do you still have the other errors?

marble shale
#

Yes, the warning popped up first, followed by the errors'

#

1 warning, 12 errors

#

really just two errors multiple times each

#

I think the warning was simply that I'd deleted the cache, no?

dusty berry
#

wait

#

before u do that

#

let me check smth

marble shale
#

Another interesting difference...

#

In package-lock.json the package versions are fairly different

dusty berry
#

what uitk version

shadow tree
#

Yeah, because I went and manually updated them to the latest versions

dusty berry
#

is on the package-lock?

shadow tree
#

But UITK doesn't get updates

#

For a long time now

#

So it can't really be different

marble shale
#

The new project has older packages...

shadow tree
#

Yep

#

Since you're in old Unity 2020, the default project template has old package versions by default

#

So if you want the default packages to be the newest versions, you have to go and update them manually in the Package Manager

marble shale
shadow tree
#

But it doesn't really matter since you don't use any of them

marble shale
#

OK, and presumably these are unlikely to be the source of the issue

shadow tree
# marble shale

And since UITK and the UI Builder are listed as dependencies in UitkForKsp2, you won't see them in your own packages manifest file

#

They're installed, but through UitkForKsp2

dusty berry
shadow tree
#

I can't see how, if you look into the Packages view in Unity, or in the cache folder on the actual filesystem, both UITK and UI Builder are installed the exact same way as for a project that directly lists them as dependencies

marble shale
#

Could it be as dumb as my project is MNC-UI but my uxml is MNC_UI?

shadow tree
#

Nope

dusty berry
#

can confirm

#

adding it via the Git bugs things

#

@shadow tree

#

shouldnt uitkforksp2 be here too?

shadow tree
#

well if you installed it, then it should

dusty berry
#

i did, via the link

#

this is wierd

#

munix

#

shouldnt the asmdef have uitk has a reference? @shadow tree

shadow tree
#

idk, maybe?

#

I don't know anything about Unity or its packages tbh

dusty berry
#

this is the reason im pretty sure

#

let me test it

dusty berry
#

well i cant seem to find the GUID reference to the UITK

shadow tree
#

guid reference?

dusty berry
#

yeah but

#

whats the guid?

shadow tree
#

no I'm asking

#

what GUID reference means

#

lmao

dusty berry
#

Oh xD, honestly not sure

#

but i got this i think it works

#

[
"GUID:023ac9b81facd43ebbb2a6f1c6252835"
]

#

idk if it forces to use GUID instead of package references

#

or what

#

the errors disaperad after i added this to the packagecache

#

lets see if it works

shadow tree
#

isn't this all we need to do?

dusty berry
#

seems like it

shadow tree
#

if the reference is the issue

dusty berry
#

yip, i was not sure

#

because i didnt know

#

that was UITK stuff

#

though it was ugui

#

thats all you need im pretty sure

shadow tree
#

alright

#

I'll update it then

dusty berry
#

@marble shale

#

well, you'll have to wait for munix to updat eit, but as soon as it does just update the package on the package manager

marble shale
#

Awesome! thanks!

shadow tree
#

pushed

marble shale
#

Not sure if I did it right. I deleted the cach and reloaded. Got the same error. What should I do? remove and re add the package?

#

Or do I need to download something?

shadow tree
#

you should just be able to go to the package manager and click update on the package

#

or maybe not lmao

#

since I can't seem to be able to do that in my project either

dusty berry
#

since its from Git i think you have to paste the git link again

shadow tree
#

yep, that updates it

#

just paste that in again

#

should jump to 1.4.0

marble shale
#

Works ! I'm building now!

shadow tree
#

great, glad that's solved

marble shale
#

Thanks you guys! I'd never have been able to figure this out on my own.

#

And now we've got a process for making a fresh clean UITK UI project!

shadow tree
#

I'm still planning to make the template for it

marble shale
#

Though it's taking for ever to build...

#

It seems to be stuck on RecompileBeforeBuild

shadow tree
#

hm, I do not have that

marble shale
#

However, all the errors are gone and there was just the normal warning for the package cache being invalidated

shadow tree
#

I'd try just closing and reopening the project

marble shale
#

It's really stuck. I may have to kill it hard

dusty berry
#

yeah probably you have to kill it

marble shale
#

It opened fine without warnings...

dusty berry
#

unity doesnt like updates like that

marble shale
#

Twice now.

dusty berry
#

yup! same for me

marble shale
#

Buyt each time the canvas is shrunken

marble shale
#

I want 350 x 750

shadow tree
#

that's definitely weird

marble shale
#

Or better yet screen size of 1920 x 1080

#

Got a successful build!

#

Also got a couple errors and warnings

#

Unexpected recursive transfer of scripted class. 'BuilderDocument' is being transferred while trying to transfer 'LiberationSans-Regular SDF'
UnityEditor.EditorJsonUtility:FromJsonOverwrite (string,object)
Unity.UI.Builder.BuilderDocument:LoadFromDisk () (at Library/PackageCache/[email protected]/Editor/Builder/Document/BuilderDocument.cs:440)
Unity.UI.Builder.BuilderDocument:CreateInstance () (at Library/PackageCache/[email protected]/Editor/Builder/Document/BuilderDocument.cs:204)
Unity.UI.Builder.BuilderPaneWindow:get_document () (at Library/PackageCache/[email protected]/Editor/Builder/BuilderPaneWindow.cs:24)
Unity.UI.Builder.BuilderViewport:.ctor (Unity.UI.Builder.BuilderPaneWindow,Unity.UI.Builder.BuilderSelection,Unity.UI.Builder.BuilderElementContextMenu) (at Library/PackageCache/[email protected]/Editor/Builder/Viewport/BuilderViewport.cs:153)
Unity.UI.Builder.Builder:CreateUI () (at Library/PackageCache/[email protected]/Editor/Builder/Builder.cs:115)
Unity.UI.Builder.BuilderPaneWindow:CreateUIInternal () (at Library/PackageCache/[email protected]/Editor/Builder/BuilderPaneWindow.cs:150)
Unity.UI.Builder.BuilderPaneWindow:OnEnable () (at Library/PackageCache/[email protected]/Editor/Builder/BuilderPaneWindow.cs:135)
Unity.UI.Builder.Builder:OnEnable () (at Library/PackageCache/[email protected]/Editor/Builder/Builder.cs:239)
UnityEditor.WindowLayout:LoadDefaultWindowPreferences ()

#

UnityEditor.EditorJsonUtility:FromJsonOverwrite(String, Object)
Unity.UI.Builder.BuilderDocument:LoadFromDisk() (at Library/PackageCache/[email protected]/Editor/Builder/Document/BuilderDocument.cs:440)
Unity.UI.Builder.BuilderDocument:CreateInstance() (at Library/PackageCache/[email protected]/Editor/Builder/Document/BuilderDocument.cs:204)
Unity.UI.Builder.BuilderPaneWindow:get_document() (at Library/PackageCache/[email protected]/Editor/Builder/BuilderPaneWindow.cs:24)
Unity.UI.Builder.BuilderViewport:.ctor(BuilderPaneWindow, BuilderSelection, BuilderElementContextMenu) (at Library/PackageCache/[email protected]/Editor/Builder/Viewport/BuilderViewport.cs:153)
Unity.UI.Builder.Builder:CreateUI() (at Library/PackageCache/[email protected]/Editor/Builder/Builder.cs:115)
Unity.UI.Builder.BuilderPaneWindow:CreateUIInternal() (at Library/PackageCache/[email protected]/Editor/Builder/BuilderPaneWindow.cs:150)
Unity.UI.Builder.BuilderPaneWindow:OnEnable() (at Library/PackageCache/[email protected]/Editor/Builder/BuilderPaneWindow.cs:135)
Unity.UI.Builder.Builder:OnEnable() (at Library/PackageCache/[email protected]/Editor/Builder/Builder.cs:239)
UnityEditorInternal.InternalEditorUtility:LoadSerializedFileAndForget(String)
UnityEditor.WindowLayout:LoadDefaultWindowPreferences()

shadow tree
#

yeah you'll usually always get some

#

as long as they disappear when you clear the console, you should be fine

marble shale
#

The font one I know will mean I'll get some log spammage.

#

I get that one twice for some reason

#

No, the second one is diff

#

Invalid value for font Keyword
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

#

They do disappear when clearing the console

marble shale
#

Well, the errors did, the shorter font one came back natch

#

I know that in my other project it remembers a different size, much bigger. There must be some way to set it...

shadow tree
#

yeah, it really should

#

I haven't seen this issue before

dusty berry
#

only way i know is the one on that link

marble shale
#

That's only temporary. it will be good for as long as you have it open, and no longer.

#

"In the same section, you can also lock the Canvas size to the size of the Unity Game Window using the Match Game View checkbox to better match a runtime UI environment:"

#

That worked!

#

I don't know how to set the runtime UI environment, but it's big enough that I can see my UI un-scrunched, and it sticks so it's that way when I reopen it too

dusty berry
#

its not hard

#

just set up a UI Document on your scene

#

and some sort of script that instantiates your window

#

but its not really needed

#

since you can preview your ui on the ui builder

shadow tree
#

all you need is to add the UI Document game object and set it to use the correct asset

dusty berry
#

well depends if the window is the default thingie

#

forgot the name

marble shale
#

FYI, I rebuilt the MNC UI using the super simple guidance Munix and Cheese first gave above. It really was super easy with just a few steps. I did this simply because I wanted it to be in a particular folder (MNC_UI), and simply changing the folder name didn't work. I'll do this with the FP UI as well, though it will be even easier now.

marble shale
tough jacinth
# marble shale Do I need these kerbalui files in my AssetBundles folder?

I don't think so, certainly not as an asset bundle. I also have them in my project as I didn't bother removing their asset bundle creation, but I don't use them. I only copy bundles I've created. BTW you can safely delete everything that's inside this folder as it gets recreated when you "Build AssetBundles"

marble shale
#

I deleted them and rebuilt the UI. They're back, so building the UI creates them. Weird, as I'm not using them for wanything so far as I know

tough jacinth
#

Yes, they're rebuild every time cause they have an asset bundle attached to them. You can set the bundle to none to stop generating it:

marble shale
#

That's odd. When I look in the Theme folder I don't see a KerbalUI.

#

I've got UITK for KSP 2 in packages, but I don't think I've got KerbalUI anywhere in this project.

#

Ahhh! I found it! It's in the package cache

#

But is it spuppoed to be there?

#

And it's here, too, in the UITK for KSP 2 package

tough jacinth
#

๐Ÿ‘

marble shale
#

@shadow tree , I'm getting this warning
[WRN 07:00:35.548] DontDestroyOnLoad only works for root GameObjects or components on root GameObjects.
for this code in FP's OnInitialized()

        // Load UITK GUI
        var fpUxml = AssetManager.GetAsset<VisualTreeAsset>($"{Info.Metadata.GUID}/fp_ui/fp_ui.uxml");
        var fpWindow = Window.CreateFromUxml(fpUxml, "Flight Plan Main Window", transform, true);
        UnityEngine.Object.DontDestroyOnLoad(fpWindow);
        fpWindow.hideFlags |= HideFlags.HideAndDontSave;```
#

Safe to remove the UnityEngine.Object.DontDestroyOnLoad(fpWindow);? What effect is that supposed to have?

#

I'm getting the same thing for MNC, naturally. Also both of these tend to spam my logs with
[WRN 07:00:35.610] Font not found for path:
and
[WRN 07:00:35.778] Invalid value for font Keyword

#

The spamming is not contiunuous, but happens initially when they first load and then whenever you interact with them.

shadow tree
#

UITK for KSP 2 already persists the objects with the UI

#

You're trying to call it on the component that's on the game object, not on the game object itself, so it's complaining

marble shale
marble shale
#

Got an issue persuading the UI to actually have and use a wider text input field. In the Unity editor it looks like this

#

Which is, in fact, what I'm intending for the Max Arrival Time text input field. This is controlled by .unity-text-field > .unity-base-text-field__input which set it this way

#

I know this is applied to the text field input as I can see it applied right here

#

And it looks fine in the editor with Preview turned on like so

#

Notice how the text input box starts just under the 'p' in the "Advanced Interplanetary Transfer" button right above it. But here's what the stinking thing does in game

#

Setting aside the red formatting, the text input box now begins just under the 'n' in the "Advanced Interplanetary Transfer" button above it.

#

What the actual fuck?

#

I've tried adding a Flex Grow 1 to .unity-text-field > .unity-base-text-field__input, but that had no effect whatsoever

#

Since the stupid thing I want to affect is a grayed out sub component of a UITK TextField object, it's not possible for me to flat out tell the stupid thing what it's stupid width is other than to use a uss AFAIK. But nothing I've done has come even close to persuading this thing to be the siaze I want it to be in game. It looks fine in the editor, but in game it's the same size (100px wide) that it was before I began fiddling with it to make it biggger.

#

@dusty berry, @shadow tree help?

dusty berry
#

im guessing this is the same issue that you had with the other inputs

#

hmm

#

if you click on the text input

#

and check its classes

#

you can see the hierarchy

#

the lower one is the more iumportant

#

if you override that one it should apply correctly

marble shale
#

So I need to do this to .unity-base-field?

#

.unity-text-field has this, but it's applied to the whole enchilada

#

And I'm making the effect I want by setting the Min width to 150

#

.unity-base-field also has nothing set for Min Width

tough jacinth
#

I'm looking at how I have textfields set up and it's pretty basic. VisualElement that holds the row of controls has flex-direction: row; width: 100%; height: 20px; justify-content: space-between; , the "<" and ">" controls have a fixed width defined and to the textfield itself I've attached a new class that has flex-grow: 1;. And that should be it.

queen orbit
#

Is there a "how to" in this thread at all?

#

found it

#

doo doo doo

marble shale
#

This whole thread is a how to... ๐Ÿ˜‰

tough jacinth
#

Exactly. Initial idea was for people to read it as a tutorial, but spam is overwhelming at this point ๐Ÿ˜„ . Luckily search works well ๐Ÿ™‚

hollow tiger
#

I think theres a fair few thousand messages in this thread

dusty berry
#

All usefull information

shadow tree
#

Right, it's true that at this point UitkForKsp2 is relatively stable (though I've experimenting with some new stuff, but I don't think anything will come out of it), so I should probably put together some docs

dusty berry
#

What new stuff?

shadow tree
#

I was trying to see if I could backport some stuff from newer Unity versions

#

because the built-in version of UITK is just so much better than our shitty prerelease package

#

๐Ÿ˜ญ

#

it actually feels stable and good to use lmao

#

but no luck

dusty berry
#

Theres a lot of internal classes and things that they use roght?

shadow tree
#

I was trying to see if I use an asset bundle with UXML/USS from Unity 2021-2023 (and inject the UIElementModule DLL from a newer version to match it)

#

it was a dumb idea but I wanted to try anyway lmao

#

turns out the asset bundle format is different and 2020 can't read those new bundles at all, and also the shaders seem to be compiled differently

#

I can't even see what shaders are in a bundle using Asset Studio/Asset Ripper with the newer bundles

dusty berry
#

Try addressables

shadow tree
#

it just throws errors

shadow tree
#

but afaik it's basically the same format as a regular bundle, just with a catalog, no?

dusty berry
#

Yeah afaik asset bundles are just easier addressables in newer versions

dusty berry
shadow tree
#

I'll take a look at addressables as well, then, we'll see

#

I think the biggest issue will be shaders, since in the UITK preview package, the shaders were simply included in the asset bundle, but not so in the built-in UITK versions

#

the whole architecture of the system seems to have changed

#

I found some of the UIR (UI Toolkit Runtime) shaders in a 2021.3 bundle which the editor builds when you build the full game, it was in like one of the sharedassets bundles or something like that

#

but the bundle format seems to be different so I don't think we could load it

full valve
#

Is there a good/easy way to change the color of the white hover/inactive hover items? Preferably in C# alone.

shadow tree
#

Usually this stuff is done with USS (where you just add ":hover" to your selector), but you could just register event handlers for the list items and change the colors manually

#

There's MouseOverEvent and MouseOutEvent

#

That should be what you need for the hover

full valve
#

Hmm, I was having some trouble with the event approach, but I can give it another shot. My main problem is list and tree view items don't show up in the editor, so it's hard to preview changes.

full valve
#

Also, is there a way to have my window always draw on top of game windows?

shadow tree
#

it doesn't do that?

full valve
#

No, it's drawing underneath some, but not all windows in the VAB and KSC

shadow tree
#

that's really interesting, must be something new in Unity 2022

#

it used to be that the UITK panels were always rendered at the very top, above all camera layers, and UGUI (which also means the game UI) was rendered using cameras

full valve
shadow tree
#

that's something we'll have to investigate, then

full valve
#

I wonder if when it's created has somethign to do with it

shadow tree
#

we had the opposite problem before, there was no way to put UITK elements into the background ๐Ÿ˜†

#

but I guess now that it's built in, they updated the system so that it can interact with the UGUI elements

full valve
#

Ha, this is why I hate UI work. Always some weird quirks

shadow tree
#

honestly it doesn't matter too much if it's UI or something else, there are always weird quirks and bugs when it comes to Unity

full valve
#

Yeah, I guess that's reverse engineering in general

shadow tree
#

you could try to create a new game object, place it in the hierarchy below the object that contains the stock save dialog, and render the UI in it

full valve
#

Possibly. I noticed that the elements drawing on top are part of the Main canvas, not the VAB canvas, located in the DontDestroy scene, not the f scene

shadow tree
#

interesting

somber hawk
#

Is this thread where I should post UITK questions? I tried to scroll to the top to read the initial message but it's soooooooo faaaaaarrrrrrrrrrrrrrrrrrrrr

hollow tiger
#

You can here yds

#

There are 3k messages here PAIN

somber hawk
#

Mkay. I have a UITK window that consists of four VisualElements that I'm using as containers. I have a bunch of buttons to swap between them. When I open my mod, I correctly see only the first container, which I refer to as the Alarms List Container. In this container is a button, "New Alarm" that should make only the second container visible.

#

The way I am trying to accomplish this is by having a windowState integer that I can set, alongside a function to use that integer to set the visibility of the various containers. So, to go from the first to the second state, I have:

#

Where RefreshVisibility() sets the visibility based on my selection

#

(I'm going to make an enum for this please don't murder me)

#

Anyways, this doesn't seem to work, and I'm not sure why

hollow tiger
#

Are you sure the callback is being calledM

somber hawk
#

Nope, should probably check that yeah

hollow tiger
somber hawk
#

nuuuuuuuuuuuuu

#

It would appear the callback is not actually being called

#

so

#

I probably made a typo somewhere

#

aaa

#

Okay

hollow tiger
#

Where did you register it?

somber hawk
#

I have a method to link all my button handelers

hollow tiger
#

Which is being called where?

somber hawk
#

At the end of OnEnable()

#

After I've gotten all the contents of my document

hollow tiger
#

Hmm

somber hawk
#

This is how it's named in unity

hollow tiger
#

Instead of clicked

#

Do
.RegisterCallback<ClickedEvent>(_ => NewAlarmButtonClicked())

#

Try that @somber hawk

somber hawk
#

sure thing

hollow tiger
#

And its ClickEvent

#

Not ClickedEvent

somber hawk
#

Still nope

hollow tiger
#

So does nothing happen or?

#

Ah wait the callback isnt happening as you said

somber hawk
#

Yeah nothing happens still

hollow tiger
#

@shadow tree im confused here

#

I dont understand

#

How is this class being added to the window @somber hawk

somber hawk
hollow tiger
#

Is there any errors in the log?

somber hawk
#

hmm, I can check

hollow tiger
#

Check both ksp2.log and logoutput.log

somber hawk
#

This looks potentially relevant!

hollow tiger
#

Thats it

#

Your callback handlers dont get registered

#

Cuz it errors before then

somber hawk
#

Yep

#

@hollow tiger

#

alkajshflkajshdf

#

contianer

hollow tiger
#

Lol
Happens to the best of us

somber hawk
#

Well, lesson learned

#

check for nulls

somber hawk
#

Is there a styling class I should use for the "header" of a window (idk what to call it, like the bar that says the name of the mod and has a close button at the top)

shadow tree
#

oh yeah, it needs to have the name "title-bar"

#

not class

#

and it should automatically style both the button and the label inside

somber hawk
#

I see

#

tyyy

#

hmmmm... is it supposed to be this big or am I do something wrong

shadow tree
#

the UI builder sometimes likes to set some random height values when creating new empty VisualElements

#

check if that is the case in your UXML

somber hawk
#

I don't think so?

shadow tree
#

oh, it has flex-grow set to 1

#

so it will try to fill empty space

somber hawk
#

Ahhhhh

#

Okay

shadow tree
#

you should be able to just delete the while style attribute there

#

and it should work fine

#

also maybe try to replace the X with ร—

#

it might look better

somber hawk
#

Will try that later, also maybe want to add a bit of horizontal padding

#

sadly have to do other stuff for a while now, but I feel like I'm getting somewhere with this

#

tyyyy for your help

shadow tree
#

glad to help

somber hawk
#

Is there a way to use an icon as the content of a button?

#

In uitk

shadow tree
#

it should be possible to just put either an Image or a VisualElement with a background as the content of the button

somber hawk
#

If I want to dynamically change the background of a VisualElement in my code, how do I reference the image I want to set it to? I assume I need to get it with AssetManager.GetAsset(), but what type am I looking for?

shadow tree
#

I think either Texture2D or Sprite should work

#

but I'm not 100% sure

#

let me look

somber hawk
#

Thankuuuu

#

I'll just try one of those myself

shadow tree
#

seems like Texture2D

#

but another way you could do this is to have the images in your Unity project, and define a class that has the different background image set, and just toggle the class at runtime

#

or analogously for more than 2 states

somber hawk
#

yeahhhhh I probably should do that

shadow tree
#

generally it's better to put images into addressables or asset bundles if you can, for load times