#π§°βui-toolkit
1 messages Β· Page 28 of 1
Ah
Have you said anything on the forums? The UITK guys seem relatively active there
Yes they didn't reply
π¦
Suddently I cannot save my style changes. For example I have class .MyLabel, I change the Font asset from default to one for font. Even press ctrl +s to save, but when I click on other class and back again, the font asset is back to default. Any ideas? I deleted Library folder now trying to find what causes it.
UnityEngine.UIElements.UIDocument:OnValidate ()```
and this warning comes also. Tho UI works just fine.
And what is with UI toolkit not saving .uxml files normaly. It saves it on Unity side, but when I check the file it self, it is not updated what so ever. Well some values are updated some not. Which is very weird.
Is there a way to save a visual element directly into a visual tree asset?
basically I want to save a visualelement I generate within a script.
Is Justify Content enforceable on items in ListView? I tried to change styles for ListView and internal ScrollView, but items still appears at the top of the container instead of the bottom like terminal lines.
Does Q<MyCustomElement>("...") work or does it not support custom elements yet? Getting a null return and I'm positive it's in the UXML π€
oooo for some reason, ui builder isn't saving the rename of my custom element, so that's probably why.
yup finds it if I leave the name null in the query. now to figure out why it isn't saving the rename...
yeah, saving a uxml doc in ui builder clears the name of custom elements. seems like a bug.
In Scroller element is it possible for unity-base-slider to occupy spaces of high-button and low-button if they are hidden?
You will need to make custom selector for that and edit slider it self. It is 100 % possible, but might need to do some hacking. If you disable by changing Display.None, then you just need to make slider height 100% instead of what it is now. But as I mentioned you will need to create smart selector for that. I suggest using Debug tool in order to select object you want and find his name and etc
how to do it is here #π§°βui-toolkit message
Well, I did almost that. I applied Display None to buttons, so they are not present on the screenshot. However, I applied Height 100% the drag-container instead of slider. But even with the solider I can only overflow space by changing Min-Height.
In my mind buttons shouldn't reserve any space if they are not displayed.
Sorry to bother you again, but I have a question related to way 1. I tried it and if I do #HealthBar.unity-progress-bar__progress it does not change anything and it also doesnΒ΄t select the progress bar. Did something similar happen to you?
I guess it indeed requires hacking because even after I removed buttons via code, the slider still didn't take their space.
not a bug. Just forgot to call base.Init in my UxmlTraits.Init override.
sorry for late reply. If you are getting this, that mean selector needs to be more specific.
please use #HealthBar #unity-progress-bar .unity-progress-bar__progress
Adding #unity-progress-bar will let you edit it correctly π
what you need to change is top and botom margins. After you remove button, make those margins to 0 and it will work as you want
omg thank you it works
Np, Have fun π
Ooof. π
Thank you, I've completely missed that bit.
no IDragHandler or IBeginDragHandler method does receive or gets called at all
Hello, is there a way to navigate through buttons with the arrow keys. I googled and didnt find anything so yeah
implementing a custom inspector with uitoolkit and auto binding seems to save the changes on each key stroke (tested with float and text fields). is this intended behavior?
i will try it. Thanks!
i asked a question that is unrelated to your problem
you can set myTextField.isDelayed = true; to only apply changes on enter & loss of focus
worked like a charm. thank you very much
haven't tested this myself but if the focus behavior works at runtime my approach would be to "emulate" a tab key down event like this:
KeyDownEvent tabKeyDownEvent = KeyboardEventBase<KeyDownEvent>.GetPooled('\t', KeyCode.Tab, EventModifiers.None);
yourRootUiDocument.rootVisualElement.SendEvent(tabKeyDownEvent);
you could trigger this logic on arrow key pressed.
but as i said: this approach is untested and feels like a workaround tbh.
I have this window done here
but in the editor it looks like this
using UnityEngine;
using UnityEngine.UIElements;
public class BehaviourTreeEditor : EditorWindow
{
[MenuItem("SDK/World/Behaviour Tree")]
public static void ShowExample()
{
BehaviourTreeEditor wnd = GetWindow<BehaviourTreeEditor>();
wnd.titleContent = new GUIContent("BehaviourTreeEditor");
}
public void CreateGUI()
{
VisualElement root = rootVisualElement;
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/SDK/Behaviour Tree/Editor/BehaviourTreeEditor.uxml");
root.Add(visualTree.Instantiate());
var styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/SDK/Behaviour Tree/Editor/BehaviourTreeEditor.uss");
root.styleSheets.Add(styleSheet);
}
}
this is the script
what am I doing wrong with
slider.style.translate = new Translate(e.localPosition.x, slider.style.translate.value.y.value, slider.style.translate.value.z);
that is causing the slider to stutter? IDK if stutter is the right word tbh
the e.localPosition.x isn't jumping around and is accurate
is translate not constrained to local?
do I need to account for the global position?
hmm seem to get it to work switching to pointerMoveEvent.position
still kinda confused between using that and localPosition
I guess
do I need to be using translate in geometrychange or something? I think that is what is causing me problems
I think because of trickledown and bubbleup that is
maybe I just need to register a change event, but still kind of confused on doing that. Since Visual Element implements the callback interface I don't need to do that again right?
in a class that inherits from it
oh derp, I forgot I should be using resolved style I think for this
rather, checking the resolved style first
okay, nvm, really figured it. I guess according to the docs pointer positions aren't saved or cached, so, doing what I was doing in the way I was doing it was basically causing it to jump between what I'm assuming is whatever value is before, and the new value I want
I want to say a null value, or 0, but it didn't do that, so idk
Is there a good way to setup runtime binding yet?
Right now I came up with this, but idk how I feel about it.
public static void BindRuntimeProperty<T>(this BaseField<T> element, Func<T> get, Action<T> set)
{
element.RegisterValueChangedCallback(evt => set(evt.newValue));
element.schedule.Execute(() =>
{
if (!Equals(element.value, get()))
element.SetValueWithoutNotify(get());
}).Every(100);
}
besides what you did you can just go straight to using a delegate?
What do you mean?
I was kind of thinking maybe using the C# INotifyPropertyChanged pattern (Not the Unity one) https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged?view=net-6.0
hmm like, I did something like this in my color picker,
public static ColorPicker Instance(VisualElement accessor, Color color, ColorPickerDelegate method)
{
if (instance == null) instance = new ColorPicker(color);
instance.currentColor = color;
instance.targetColor = color;
accessor.RootVisualElement().Add(instance);
instance.style.display = DisplayStyle.Flex;
instance.colorPickerNotify += method;
return instance;
}
with
public delegate void ColorPickerDelegate(Color color);
public ColorPickerDelegate colorPickerNotify;
can do that for your pseudo binding. It is basically what you already did since that is the base of bindings, it's just going straight to it yourself and making one hehe
That is only one way 'binding'.
what do you mean? I was more of thinking doing something as such allows anything to be notified and to essentially be able to pseduo bind? Maybe I don't understanding binding though. I just recently have been able to get back into this after a couple month hiatus, so refreshing myself at same time
I mean that if something changes float myFloatValue;, I want the FloatField that is 'bound' to it to update and if the FloatField changes I want float myFloatValue; to change as well.
yeah, okay, that is why I was sharing doing a delegate. You just subscribe everything you want to change to it, and when the value changes, it will change it for everything,
but what you have is basically doing that already with action and func, I was just mentioning delegate so if you want to go a step... down? I think it is
I guess I don't understand what you mean then
so what I mean is I subscribe something like
void UpdateColors()
{
if (targetColorContainer != null) targetColorContainer.UpdateTargetColor(targetColor);
if (redContainer != null) redContainer.UpdateValue(targetColor);
if (greenContainer != null) greenContainer.UpdateValue(targetColor);
if (blueContainer != null) blueContainer.UpdateValue(targetColor);
if (alphaContainer != null) alphaContainer.UpdateValue(targetColor);
}
to the above delegate lets say, so all these things are update on a value change. So what I was getting at was besides what you are already doing, you just do something like this with any value and any field really.
let me see if I can get a more specific route
So you mean add an event to my data class for when each value is changed?
you don't have to do that. Was just an alternate route, personally, for your question and already using Visual Elements, to be exact what I would probably do is use ChangeEvent<T> already built into visual elements on a method that caches the value in every field I want it to.
For example,
// Event callback
private void OnBoolChangedEvent(ChangeEvent<bool> evt)
{
// Handling code
}
Larger example from the manual if it helps
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
public class ChangeEventTestWindow : EditorWindow
{
private Toggle m_MyToggle;
[MenuItem("Window/UI Toolkit/Change Event Test Window")]
public static void ShowExample()
{
GetWindow<ChangeEventTestWindow>().titleContent = new GUIContent("Change Event Test Window");
}
public void CreateGUI()
{
// Create a toggle and register callback
m_MyToggle = new Toggle("Test Toggle") { name = "My Toggle" };
m_MyToggle.RegisterValueChangedCallback((evt) => { Debug.Log("Change Event received"); });
rootVisualElement.Add(m_MyToggle);
// Create button to toggle the toggle's value
Button button01 = new Button() { text = "Toggle" };
button01.clicked += () =>
{
m_MyToggle.value = !m_MyToggle.value;
};
rootVisualElement.Add(button01);
// Create button to toggle the toggle's value without triggering a ChangeEvent
Button button02 = new Button() { text = "Toggle without notification" };
button02.clicked += () =>
{
m_MyToggle.SetValueWithoutNotify(!m_MyToggle.value);
};
rootVisualElement.Add(button02);
}
}
I'm sorry I don't think I really understand still.
This is what it is now, not quite as clean as I would like but not too bad.
floatField.BindRuntimeProperty(() => _example, value => _example = value);
sounds good! Thanks for sharing also, trying to do a lot more things with the uielements at runtime, so this will be helpful
Sure thing!
I think I could get it nicer using Expression Trees, but the cost of binding would shoot up.
I really should check out the com.unity.properties and com.unity.properties.ui packages
I haven't checked those out. I haven't checked out anything also in the 2022 versions yet haha. Just got back into my Unity stuff and kinda trying to catch up where I left off
They are still 'experimental' it seems. Ah yeah, coolio! I am going to be doing a lot more with runtime UITK I think, it seems pretty nice.
I have been trying to do it all from C#. Like, I haven't used the UIBuilder at all haha. IDK why, I find it a lot of fun, but, I'm also doing it in hopes I don't need to rely on whenever Unity devs release more things
Is there a 'hierarchy changed' event for when a VE is added or removed as a child?
https://docs.unity3d.com/Manual/UIE-Panel-Events.html if you didn't find it already
I was looking for an event where a child is added to another VisualElement. Turns out there isn't one. There is a internal C# event for it though. Not sure why they haven't made it a proper event...
I can seem to find a built in controls list, but is there a built in default actions list for a visual element? Trying to make sure I'm not double dipping? an subscribing to events that are already subscribed to?
or can I assume https://docs.unity3d.com/2022.2/Documentation/Manual/UIE-Events-Reference.html is all the default events a visual element is already subscribed to
also, is disabling picking mode on visual elements that don't need picking mode beneficial, such as, visual elements holding non changing labels? Just realized I haven't been disabling this on Visual Elements that I haven't really thought about. most just on aboslute visual elements that I don't want to actually interact with but want On Top
also, shouldn't
protected override void ExecuteDefaultAction(EventBase evt)
{
Debug.Log(evt);
//base.ExecuteDefaultAction(evt);
/*if (evt.eventTypeId == GeometryChangedEvent.TypeId())
{
Debug.Log(evt.target);
}*/
}
without base prevent defaultactions? It doesn't seem to
Hello, using UITK 1.0.0-preview.18 and unity 2020.3.30f1 everything works in editor but I have no UI in build. the log shows this message
Any clues on what I'm messing ?
when I track x and y position in an event for a pointer, it starts from the top left corner. 2DTextures are generated from the bottom left corner. I just solved this by subtracting the pointers yPosition from the height of the 2DTexture, but, was wondering if there was something else already in place that deals with? Like, if I use absolute in the visual element or something?
my runtime color picker slowly, but surely coming together
so I just changed my pointer to look like this, and I did it with
pointer.style.backgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
pointer.style.borderLeftWidth = 2;
pointer.style.borderTopWidth = 2;
pointer.style.borderRightWidth = 2;
pointer.style.borderBottomWidth = 2;
pointer.style.borderTopLeftRadius = 5;
pointer.style.borderTopRightRadius = 5;
pointer.style.borderBottomRightRadius = 5;
pointer.style.borderBottomLeftRadius = 5;
pointer.style.borderLeftColor = Color.black;
pointer.style.borderTopColor = Color.black;
pointer.style.borderRightColor = Color.black;
pointer.style.borderBottomColor = Color.black;
obviously that works, but, made me wonder if that is the ideal route
OK, made it work, apparently you can't instantiate a prefab that has a UI document to then set the panel settings, and source asset...
are you sure? I do that, but, I'm not on that far back of a Unity
well Instead of instantiating my prefab containing the ui document and then populating I added it to the hierarchy and used Object.FindObjectsOfType<UIDocument>()[0]; to get it and use it and now it works in build so....
I'm still kinda confused on this, when should I be reading from properties in style vs resolvedstyle vs layout
Like right now I'm finding a lot of the things I do I actually do through the GeometryChangedEvent and wondering if that is what I'm suppose to do
I'm having a hard time figuring out how to also handle the ExecuteCommand waiting if I try to pass data to a visual element that hasn't had a frame go by yet
like, I'm doing things now where I'm caching data that doesn't need to be so that it's there when the gemoetrychangevent happens, but, maybe this is the correct way?
How would I go about making a vertical layout group I can add and remove images from at runtime?
Is it not possible to apply transitions when adding a class to a selector? only for pseudo-class changes?
Been trying to using a unicode from RemixIcon (ttf), and it just comes up as a unknown symbol box :/ (used a unicode viewer to find/double check)
hi, I'm trying to crate a custom property drawer with UXML, but I get a "No GUI Implemented" message in inspector
I load the UXML file this way
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>
but I don't understand what to do with it
As I understand it you have to override
public override VisualElement CreatePropertyGUI(SerializedProperty property)
and return the resulting root VisualElement. The loaded uxml visual tree acts as the root visual element, so all you have to do is instantiate it, then setup the styles etc and access the serialized properties to bind things.
eg:
public override VisualElement CreatePropertyGUI(SerializedProperty property) {
var uxmlVisualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("path");
VisualElement root = uxmlVisualTree.Instantiate();
return root;
}
can you use with UIToolkit
oops
Graphics.DrawTexture
I didn't know if that would be better than style.backgroundImage?
or is that what it is already doing?
does style.backgroundImage automatically Reinitialize? Or do I have to take care of that myself
Is it possible to do any kind of animation with ui toolkit?
Does anyone know if comparing GeometryChangedEvent.newRect.size with ``GeometryChangedEvent.oldRect.sizehas the floating point precision problems and I should useMathf.Approximately` with it?
rather, COULD have the problems
Sometime toggling/adding classes just never seem to trigger transitions, while pseudo-classes are always fine. I have no clue what could be the issue, this never happens in CSS.
TransitionStartEvent never even triggers, are there particular cases in which style changes won't cause transition of properties despite them working fine on pseudo-classes?
Not fully familiar with all of UIToolkit, but, is there an event you should be registering to similar to GeometryChangedEvent? For example, I do a lot of my children initialization in this event on the "parent" visualElement because of values I want to do things from that don't exist till after the layout phase
Is it all values added inline to IStyle have to wait a frame to be read, or, is that specific to rect size and position?
that being said, what event do I register to outside of GeometryChangedEvent for any IStyle change?
The style involves a width change.
I have found out transitions will only happen properly if attached to an event.
GeometryChangedEvent will trigger when the width is changed. So far I'm thinking of just registering to it and slightly changing the width or position of the element beforehand to trigger the real width value transition.
I'm wondering if there's a way to manually update the VE and if there's an event associated with VE updates.
I know you can register to value change events, but, for some reason I seem to be failing to get this to work
so like, you can register to do an ExecuteCommand I think it is in a value change event
I think this one only applies to IMGUI?
Managed to dispatch a synthetized event from a pooled GeometryChangedEvent with proper VE target, the style change registered to this event. The result is the same, it ignores and produces no transition Start events.
I've found the issue, it seems that ContextMenu methods that change IStyles won't trigger the TransitionStartEvent, Anything else is fine. Bug?
Technical artists who are familiar with Unityβs GameObject-based tools and workflows are likely to be comfortable working with GameObjects, Components, and the Scene view.
They might not be comfortable with UI Toolkitβs web-like approach or IMGUIβs pure C# approach.
Internal screaming intensifies
It's not really that bad right? Right? π¨
It is quite lovely actually
That sounds nice π
UI Toolkit feels very homely if you do front-end web development
"web-like approach" gave me shell-shock flashbacks to CSS and HTML
I mean, you best dust off those skills
UXML and USS are basically HTML and CSS respectively
Just tell me it's not gonna take 17 lines of arcane nonsense to center a div π
With CSS the problem is mostly the need to work on like 900 different platforms in different ways but since this unity stuff is just for unity...
No, we don't use divs, we use flex-type stuff
Whatever the equivalent is π
And also, we have a visual editor
Every time I try to do something that seems like it should be simple in front-end web dev it turns out to actually be this arcane riddle with specific, not-always-intuitive black box answers
"Just use this and it works"
It is more similar to WPF if you ever tried that
windows presentation forms
Oh not familiar with that... I guess I'll jump in and see π
But, It is much more preferable to Unity's old system for UI, though at this time it is not feature complete
Oh? Is it missing enough that I should hold off on using it?
It is a GameObject-based UI system that uses Components and the Game View to arrange, position, and style user interfaces.
This sounds so much more pleasant to use I don't know if I can resist the temptation
https://docs.unity3d.com/2020.3/Documentation/Manual/UI-system-compare.html
This page is very helpful
I'm having a lot of trouble wrapping my head around why the cascading style sheets format is warranted for game UIs short of making some menu-heavy 4X game or something
I mean the default is pretty servicable for UI
The default's for UI Toolkit look better than the defaults for IMGUI, NGL.
Yeha IMGUI seems like it's mostly for debug type stuff
I prefer to try and force myself to learn the newer system... like the new input system is fantastic and way better than the old imo
But in this case the newer system is really NOT selling itself to me 
Webdev is my kryptonite
What I would say is that it is best to sell itself once you open up the editor and quickly debug out a UI
And then compare that to the old one.
Hmmmm yeah I guess I should at least toy around with it a little rather than take my prejudices for granted... 
One thing I noticed on the feature comparison page is that it says it does not yet have integration with the new input system
I have trouble selling it similarly to selling the new input system. It is that everything just works once it works.
Not sure exactly what that means π€
Oh yes, that...
So, it uses the old input system on it's backend... which forces you to not only use the new Input System.
for 2020.3 at least
Oh π
I mean, I imagine that feature will get rolled out very soon.
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/UICanvas.html
I must be crazy because when I read the description of how this system works it makes 10000x more sense to me than using a webdev style
Webdev is more programmer friendly
HTML/CSS aren't programming it's like design/configuring
Well, programmer friendly for me, after I built a tool to fix the problems
When I read this
UI elements in the Canvas are drawn in the same order they appear in the Hierarchy. The first child is drawn first, the second child next, and so on.
I literally pump my fist and go "Yes!"
It just seems really intuitive for the use case
Again, I ain't good at selling this, the real goal is to apply modern programmer-UI paradigms, which is that the view, the styling, and the code should be seperate.
The idea is that you can then rework the view/orientation of how everything is laid out and the styling and code will still work right.
you can change the styling and the view and code will work right
and you can change the code and the styling and view will work right
UI Canvas has a design issue wherein those things are all effected by eachother
which is that the view, the styling, and the code should be seperate.
Yeah this is pretty much what keeps me out of webdev. I find it super onerous and the premise that you can change one thing without having to change others rarely works out in practice. I know I'm almost certainly not right given the overwhelming support for doing it that way, so I figure the domain just isn't meant for me π
Having to swap between the 3 files constantly makes me mental, the infinity of different css tags and their arcane specific interactions... I just want to write code that does things π
I think UI Toolkit makes UI a lot more scalable.
For small stuff, they are pretty similar.
Yeah I can start to see the value of that sort of system if we're talking about something really menu heavy
Like EVE Online/Elite dangerous or something
or a 4X or something... but not like DOOM
I mean, I don't think the game that I am developing would be as easy as it was without UI Toolkit: https://crazyjackel.github.io/SF/Builds/Alpha/0.0.4/
And also me building tools to make UI Toolkit work
I think it is hard to justify if you are dedicated to the New Input System at this time, but one cool thing is that we will get shader support in the future.
I mean honestly I was ready to just give in and force myself to use it under the assumption that wiser people than I have decided this is the way for a reason... until you told me I'd have to make use of the old input system π
Honestly, I am not the best person to sell this to anyone. I just prefer the work style.
Oh for sure
If you are already comfortable with the way web dev works then obviously it's probably delightful
well, no, I just really liked WPF when I worked with it and ReactiveUI
and when I saw Unity was doing that I was happy.
Because ReactiveUI and MVVM (or MVC) is such a great paradigm for making dynamic UI.
I guess I've never gotten deep enough into UI stuff to start to really appreciate MVC
I've worked with quite a lot of different stuff like that but never very deeply as I always retreat back to ... whatever you call non-webdev coding. C# and Java and whatnot π
It always just felt to me like every time I changed anything I had to do it in 3 places
Generally, I think building out the structure of the application via some Markup Language, choosing how it should be stylized, and then Binding it, is much preferable to carefully laying out Objects, stylizing it as an attachment to the UI, and then selecting C# scripts that may cause breakages if they ever are destroyed.
The style system in general allows for me to change every single similar piece of UI all at once instead of individually having to go and do it to every element
Or having to write a giant system to do that
Yeah. It sounds worth dealing with, and since my use case has fairly simple UI requirements it likely wouldn't require sinking too deeply into anyways. But I suppose I'll wait on the input system before I give it a shot
Right now, the biggest issue IMO for the UI Toolkit system is connecting up data. I wrote a package to handle it for myself: https://github.com/crazyjackel/redmoon-reactiveKit
It is really homely for me
What exactly do you mean by this
connecting up data
Okay, so let's say you click a button, what functions should that button call?
Go on π€
Or is that no rhetorical? Lol I dunno whatever is subscribed to it
Depends on how the buttons work in this context
The issue is setting up those subscriptions
They required an external tool surrounding the UI to hook up. In my case, I just grab the Button class in scripts and use UniRx to have it call commands.
button.BindClick(viewModel.OnButtonClick).AddTo(disposable);```
By default, such a system doesn't exist
Which means that the UI is mostly static until you make such a system.
Now, I am not the only person who made such, there is something called Graphene, but personally, I wanted something with UniRx integration.
And what is UniRx π€
UniRx is Reactive Extensions for Unity, it basically combines data and callbacks together, so that whenever you change a variable, it emits a signal that it was updated.
It is an implementation of the 'Reactive' concept for Unity. It produces some very elegant code, for say, detecting a double click:
clickStream.Buffer(clickStream.Throttle(TimeSpan.FromMilliseconds(250))).Where(xs => xs.Count >= 2).Subscribe(x =>
{
viewModel.OnDoubleClick.Execute(x.Last());
});```
What this code does is it takes an Observable, which is something that will emit a signal when it observes a change in a value, buffers those values over a period of 250 milliseconds, checks that there exists more than two, and then subscribes to execute a function.
nywy, I need to go get some sleep, I am working on a new package concept for a 3D Block-Based Tilemap and if I want it to work, I have to bang my head against a wall Tommorrow.
Thanks for the tips and for entertaining my curiosity π
Following this guide:
https://learn.unity.com/tutorial/ui-toolkit-first-steps#61df0df2edbc2a464153734c
The button is not being shown with the CreateGUI method. CreateGUI doesn't seem to be getting called. Anyone have an idea why?
Changing it to OnEnable works, but I wonder why CreateGUI is not being called.
Is it possible to have child selector in USS be relative to parent? f.e. I have a textfield that I am overriding the styles from and I would like the lower level field to inherit the border color and size instead of having to hardcode that in the USS. Is that possible? ```css
.default-text-box {
width: 100%;
font-size: 66px;
border-radius: 20px;
border-left-width: 2px;
border-right-width: 2px;
border-top-width: 2px;
border-bottom-width: 2px;
border-left-color: rgba(205, 205, 205, 255);
border-right-color: rgba(205, 205, 205, 255);
border-top-color: rgba(205, 205, 205, 255);
border-bottom-color: rgba(205, 205, 205, 255);
margin: 0;
padding: 0;
}
.default-text-box > .unity-text-field__input {
border-radius: 18px;
}
note that the value is not exactly the same because of padding on the inner element, can I calculate the radius of the second element based on the second? Something like (parent - 2px)
You have to hard code everything atm
Can I assume that inheriting styles will be coming at some unknown point in the future?
Or is it unlikely to happen withing the UITK framework (at least natively, I could just use C# if I really wanted to)
They'll be working towards all sorts of common and successful things in web. SASS is certainly one of those
It's not close though as far as I've heard
Alright, I'll keep up hope for it in due time. For now I will just have to work around it
Is there a problem with the UITK TextField Password property? Every time I save after editing the style of the field and save it just resets to non-password
<?xml version="1.0" encoding="utf-8"?>
<engine:UXML
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:engine="UnityEngine.UIElements"
xmlns:editor="UnityEditor.UIElements"
xsi:noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd"
>
<VisualElement class="quicktool-button unity-button">
<VisualElement class="quicktool-button-icon"/>
</VisualElement>
</engine:UXML>
Am I understanding this correctly? In the above UXML there is this part: class="quicktool-button unity-button" Is this linking custom USS styles defined with ".quicktool-button" in addition to a built in USS style defined as "unity-button"?
Is it known bug taht on 2022.1.0b13 and 0b14 you cant press on dropdown buttons? how ever it works, when using debug inspector, but in editor and build it doesn't?
Yeah. I think it was incompatibility with the input system?
Thanks. So I guess I just need to wait until it will get fixed? or there is known workaround? As I was forced to work on 2022 on project π
field.RegisterCallback<ClickEvent>(evt =>
{
using KeyDownEvent keyEvent = KeyDownEvent.GetPooled('\0', KeyCode.Return, EventModifiers.None);
((DropdownField)evt.target).SendEvent(keyEvent);
});```
this is my shitty workaround
Thank you! work around is an workaround <3, regardless π
(it simulates a keypress on it when you click it. Keyboard interaction works fine)
@rough scarab β€οΈ it works flawlessly π
nwm I just set default font for everything and it works.. Kinda π
hi, is it possible to achieve inheritance in custom editors with UXML? I have a hierarchy of ScriptableObjects, let's say A <--- B (b inherit from A). I have a custom editor for A and now I want to create a custom editor for B but recycling A interface UXML file
I'm trying to make BEditor inherit from AEditor, but I'm not sure how to handle this case and if it's supported
does anyone know why when I create a font asset the file is massive (>2mb), but the ones from Unity are small, like 6kb?
It might depend on the type of font file used as the source
Most likely because of options you use. Resolution for example, scale, spacing and etc. And are you comparing font with font asset?
Hello, does anyone know how i can place a game object in front of the ui?
Hello, has anyone ever integrated a serialized UnityEvent into a custom inspector or editor window using UI Toolkit? And how?
need to make custom control? π€
This thing is what I mean
i am trying to use a ObjectField but for some reason none of the objects of with the component types are showing up. I have set the objectType to one of my MonoBehaviors and I see no prefabs with that type of component.
I can still drag that type in and it shows the correct type. Just can't select one through the selector menu
Okay I need some serious help
I cannot get my buttons to work at all
settingsButton.clicked += SettingsButtonPressed;
Leads to the error
NullReferenceException: Object reference not set to an instance of an object
MainMenu.Start () (at Assets/UI/MainMenu.cs:47)
Nvm found the issue
Okay some actual help needed. I want to call a method ONLY when a slider is adjusted by the player. Is there any way to do so?
@wind olive This is uGUI isn't it? I need help with UI Toolkit
didnt see what channel myb lol
Lol it's okay
I'm having trouble navigate/comprehend the documentation for UI Toolkit
I find it strange that a Visual Element does not have an event tied to changing enabled status
or even class changing events
What is on line 47 of MainMenu.cs and what is settingsButton?
It was a pain, but I got am event now for when the hierarchy changes! (element added or removed)! π
Does calling Unbind() on a VisualElement unbind it's children as well?
If I remember correctly yes it does
Ty
There seems to be a bug with the UI Toolkit's PropertyField class. It doesn't seem to keep track of the isExpanded value on arrays correctly. It always shows the serialized array as expanded when GUI gets created again even if I manually closed it previously.
It doesn't happen when using EditorGUILayout.PropertyField in OnInspectorGUI. Only seems to be a problem with UI Toolkit.
At least it is a problem in the version I'm using, 2021.2.10f1
Hey, I'm trying to use the UI Toolkit in the unity runtime and I can't get the mouse events to work. Button.clicked DOES work, but the MouseEnter and MouseLeave events do not.
Does anyone know why this might be failing?
Make sure nothing is blocking it in scene
OK, so these CAN be blocked.
OK, that was it, it was just being covered by stuff.
Thanks @tribal fable
Question, I need to put a TMP file inside a script for a text file I believe
So the tutorial said "make a text, put it in that spot in the script"
but I have textmeshpro installed, and I cna only create a textmeshpro now, and the script doesn't want to take that kinda object
there seems to be a lack of documentation on how to actually use the input system with ui toolkit
i have a dynamically populated list view and want to navigate that (up, down, enter) with both kb/m and gamepad
how would i do that?
I would index all of the buttons in a particular menu and have the up/down on kb m or gamepad iterate through them
starting at 0
the important interaction between the input system and the UI system is the input module on the event system
Hello guys, do anyone know the simplest way to do this? I need to have panel that is dark and transparent and second object where dark panel will not affect it. On that way I will be able to highlight some specific objects in UI. Do anyone know the simplest way or some asset on the store?
I have the Problem in the Ui Tookit that i hide and show panals. First it works and if i disable it and make it visible nothing happend. It shows the panal not again. what is happend ?
If you enable and disable the object with the UI Document in it, the entire UI Tree is regenerated. This means that all object references are invalidated.
I have no idea if this is the correct method for doing this, but when I need to hide an entire panel or screen - I use 'RemoveFromHierarchy', and then, to show it again, I add it back to the hierarchy.
This leaves pointers intact, and does not regenerate the tree.
Thanks, I'll take a look and adjust it. I did not know that it recreates the whole tree. In the old canvas you could enable and disable elements
Yeah, confused the heck out of me too.
el.style.display = DisplayStyle.None; (to show: DisplayStyle.Flex) is what we use and I believe the recommended way to optimally toggle "visibility" of elements. Opacity => 0 (or visibility I think) can be used if you want to maintain the same layout as if the element was there, just not render it. In practice I've rarely seen a need for it though.
So i discovered this exist by accident today and wanted to learn it, any up to date tutorial available?
how can I set a button selected state programmatically, with just c#?
I see pseudoclass in the docs, but not quite sure how to adapt that
does anyone know if comparing if (e.newRect.size != e.oldRect.size) I should use some sort of approximate instead?
hi, I try to use a Slider(Int) in my new UI and i cant find, where i can change the size of the slider. And is it possible to add a field where you can see the current value of the slider?
is there a way to use absolute positioning when uhh doing a position check compared to a texture? I just have to keep doing something like
float yConversion = Mathf.Clamp(saturationContainer.layout.height - saturationPointerY, 0.0f, saturationContainer.layout.height - 1);
in several areas
oh, and that is from the PointerMoveEvent.localPosition
I guess I could just make a static function, but, I didn't know if there was something already in the events I'm missing
do any of you know if doing pickingMode = PickingMode.Ignore; on an element that you don't plan on doing anything that involves picking mode is more efficient than not doing it?
and also if that is something that inherited, so if I have a parent with that enabled, if I need to disable it on a child
It's not inherited, and yes, I would do it on anything you don't want clicked personally
okay, ty!
Is UI Toolkit going to support shaders, 3D models and such?
So far, the only examples I've seen are for minimalist-styled UI
According to this info, its in the "Planned" phase. https://unity.com/roadmap/unity-platform/gameplay-ui-design
Which doesnt tell us much.. Could be next week, or in 5 years.
out of curiosity. Are spite atlases used by the ui toolkit? Just wondering what's the optimal way to use sprites? I was having issues when assets weren't located in resources (maybe just a bug)
i'll be using a mix of sprites that will be part of a build but i'll also have some swapped at runtime
What do you mean? You can change a UIs background image with style.backgroundImage for a texture. There is an option for sprite and renderTexture and vectorImage, at least on the version I'm using
So to clarify more. To save in draw calls in the previous UIs you would want to package sprites into a single atlas. I am just trying to figure out how the UI system handles the sprites. Does it package them if they aren't in an atlas? If they are in an atlas does that save memory and draw calls? I just want to understand how the system is handling the assets assigned.
How can I get and change VisualElementFocusRing.defaultFocusOrder?
Hi pals
How can I link a nice USS stylesheet to a Button (or any other) object created with Unity UI ?
I got a nice base AI that I need to pimp up a bit
Considering it needs to be simple to modify and maintain even after I leave the team, I need it to be with something as simple as USS style sheet
Thanks !
USS ?
i didnt even know tthat existed lol
it seems amazing but I fail to find anything really useful
Unity UI (UGUI) is a completely separate system than UI Toolkit. USS is not designed for it, and I doubt anyone would have made anything handle it, as it's not designed to use it, and is an in-progress replacement. UGUI's styling is done via prefabs, or direct code modifications.
Ok ! Ty
How Can I code the style so that it's practical ? Any tutorials or stuff u recommend ?
Is it possible to create instances of a UI Document? I would like to create 2 (or more) separate versions of my overlay UI
is it possible to stop ExecuteDefaultAction without inheriting from VisualElement? Can I do it somehow on a VisualElement field?
I guess I could just make a new VisualElement container that inherits from it, and then make the override public idk
Is it possible to mix UGUI and UI Toolkit?
Yes, but, no also? UI Toolkit has features in it to allow UGUI elements in a sense, but, not the other way around
I'd like to use a file browser asset that uses UGUI, but I use UI Toolkit in my game
So that might work?
What do you guys think about with a helper/utility class for UIToolkit? Originally what I have been doing was in a lot of my classes at the bottom I have an initializeUI type function that uses UIToolkit to display info I want to display in that class. I want to remove that further and do something like
public static class ExampleClassUIToolkitDisplay
{
public static VisualElement Display(this ExampleClass)
{
//code
return visualElement;
}
}
However, IDK if this is a good route to go?
It depends on how you want to organize your stuff. I have non-static classes derived from VisualElement, and I pass a reference to the thing I want to display in the constructor.
When it comes to the editor, Unity uses IMGUI, which I don't know if takes priority or not over UIToolkit in terms of display
ohh, I believe you can technically use either or, but, I don't know which one would take priority for display, however, UIToolkit has a container for UGUI
I'm trying to find the exact thing for it for you
I haven't been able to find it in the manual, but that's not surprising
If you look at the UI Toolkit debugger it's called IMGUIContainer, which I just realized is not the same thing as UGUI
so let me see
I think it's only IMGUI, but it seems to be possible to combine them
Seems I can just use both, and set the sort order to display UGUI on top
I have zero experience with UGUI, but I guess I can just try
I'm sorry I can't be of more help, a while ago I started learning UIToolkit and kinda stopped looking at all the other UI tools
Thanks anyway!
Your approach of using extension methods for display sounds fine btw, if you want to separate the UI code out of the game logic
If you want to go further you can also define interfaces for your game objects and use the interfaces as arguments to the display method, that way you can use the same display function for different game object classes.
But you can also just do that for those things where you need it
Like you have enemy : ICreature and ally : ICreature, and then Display(ICreature)
And ICreature has just the stuff you need for display
Okay cool. I was mostly thinking about if I ever used something like UGUI or IMGUI I could split away from having code for UIToolkit, if that makes sense
so was trying to think of a route to go for that
IMGUI isn't for runtime afaik
so like, I've been making a custom color picker in UIToolkit, but want to still keep the core parts of the color picker still in tact
yeah, but I mean more than that, like, if I ever want to try and implement this color picker another program or something
Yeah it makes sense to have the logic separate from the display
Loose coupling and all that
idk, but I'm also doing this to learn more about uhh what's it called, to teach myself to better make classes not rely on other classes?
If you want to read how the pros do it, look up MVC
MVC is just one way to split off the display from the logic
But it's a very frequently used one
I'm doing just model and view though, with controller stuff sitting in the model class
@hollow jacinth I think instead I decided to make a non static class, and just have a null field of just some helper class till it doesn't need to be null anymore
just the way I'm setting this up I don't think I want to have a bunch of static fields just hanging around
Why static fields? Static classes aren't a problem, static fields can be (according to every code smell analyzer)
hmm IDK, I'm actually not very familiar with static outside of extension methods and doing the singleton pattern, so just assumed all the fields in that class would have to be static also
Yes they do, but you probably don't really need any fields in that class
Unless you want to have some general parameters to control how something is displayed
In which case the problem is you have to remember to set those before you start building your UI
Well, I do a lot of my UIToolkit stuff in code, and I don't like using the query system as much, so I use fields for basically every visual element to cache lol
even though for some reason the UIToolkit page says you can't do this, I do
so idk why it does
Then you might want to just derive a class from VisualElement
It wont be static that way, but you can just use a constructor to pass in a reference
yeah, that is kinda what I think I'm looking at, just started this one but something like
public class ColorPickerUIToolkit : VisualElement
{
public ColorPickerUIToolkit(VisualElement parent)
{
}
}
Yeah, but also probably public ColorPickerUIToolkit(VisualElement parent, ColorPicker picker)
You have to put in the reference to the thing you want to display somehow
I'm doing the singleton pattern on my ColorPicker, only reason I didn't include it
Ah, okay
so static ColorPicker instance;
Well, I got to go
okay, have a good one
You too!
Is there some way to make my UI Document inherit position from parent?
I have a UI panel overlay on each of my game board prefabs, and I've got 2 of them (game boards) in the scene, in different positions, but both UI panels are in the same spot
Is there any documentation on the included tabbedview and tabbutton scripts? I would like to have tabs in my UI
I think you have to use world space UI? I don't have any experience with that. π¦ I think it's in the docs somewhere though.
If you want to have the panels in screen space, you can have a visualelement in there that you set to the position (and size) you want with position : absolute, then just put your stuff into that visualelement
You will have to keep it synced with your game objects' positions somehow though
Using world space UI sounds like a better idea if you can get it to work
Sometimes my canvas ui elements delete onclick and other times they dont
anyone know the problem?
I do have a custom cursor
can someone explain the difference between the following?
what i want is for the ListView items to be aligned in the center, but at the bottom of the screen
for some reason, setting "Align Items" to Center breaks the layout and i can't figure out why
I'm not sure the best way to approach this error Invalid width (0) or height (0) used for creating mipmaps. which is triggering from
void OnGeometryChangedEvent(GeometryChangedEvent e)
{
if (e.newRect.size != e.oldRect.size)
{
draggerBackground.Reinitialize((int)draggerContainer.layout.width, (int)draggerContainer.layout.height);
draggerBackground.Apply();
}
UpdateDragger();
UpdateInput();
}
which is from
public void Close()
{
style.display = DisplayStyle.None;
}
the DisplayStyle.None is happening on a parent visual element, so didn't know if I should just track the parents visibility or
maybe I should have all events unsubscribed from when it closes? hmm
I was thinking that it wouldn't have mattered since the parent isn't visible
well guess I could probably also just do if (e.newRect.size != e.oldRect.size && e.newRect.size != new Vector2(0.0f, 0.0f)) but IDK if that is a correct route?
Hi folks! I'm using the new UI Builder and I've added a slider. I managed to customize the look by using USS, but I can't figure out how I can set the color of the filled slider. Eg:
The left hand side of the slider should be a different color because the value is selected
what happened π€
Referring to my deleted messages? Felt it was unfair to complain about ListView without offering how I think it could be improved. Going to try using binding path to see how much binding could be done automatically vs binding each prop like I was doing before. Could be that I'm just not using that to it's fullest potential.
instead of just trying to 0 out a value I should use the StyleKeyword.Null correct?
as an example
if (value == SliderDirection.Horizontal)
{
container.style.flexDirection = FlexDirection.Row;
dragger.style.top = -2;
dragger.style.bottom = -2;
dragger.style.left = StyleKeyword.Null;
dragger.style.right = StyleKeyword.Null;
}
if (value == SliderDirection.Vertical)
{
container.style.flexDirection = FlexDirection.Column;
dragger.style.left = -2;
dragger.style.right = -2;
dragger.style.top = StyleKeyword.Null;
dragger.style.bottom = StyleKeyword.Null;
}
I have a problem with a canvas blocking my ui builder button. Is there a way for the ui toolkit to intercept the click events before the legacy ui?
biggest issue i suppose is that the legacy was set to overlay.
How do I define multiple RadioButtons to be in different groups? I have 5 radio buttons on a single screen but there should only be an interaction between 3 and the other 2 not all 5 at once
if I click on any of the 5 radio buttons, it disables the other ones
I'm still somewhat confused if someone could help. We have layout values we can read from, and resolvedStyle values. Obviously, these both produce different things, but, can also produce the same thing. Is there any difference between one of them I should prioritize reading from if both can provide the same answer? For example, layout.width and resolvedStyle.width
iirc resolvedstyle keeps track of percentage based styling after the layout step, while regular layout is just the initial pixel value
you should listen for the style resolved event before reading the value tho
wondering if I can get help with I'm possibly doing wrong here?
if (sliderDirection == SliderDirection.Horizontal) dragger.style.translate = new Translate(draggerContainer.layout.width * (value / maxValue) - (dragger.layout.width / 2), 0, 0);
Just noticed that my max doesn't seem to be lining up correct, though I have the input field with the correct value, I guess I could have something else wrong, just assuming this section
wondering if some floating point precision is happening and I need to clamp that also
I have a very large, deeply-nested object that I'm trying to write an editor for. Essentially, one SerializedObject with a ton of SerializedProperties. But I don't want to write my editor in that way. I can't control the underlying data model, but I want to split up the editor in sensible ways. To do that, I've tried to wrap my UXML docs in a BindableElement, so that I can bind properties to the root of the UXML docs. It was my understanding that setting the children binding path's would propagate the relative properties of the root property to the child elements. Is this wrong?
Simple example:
public class Item{public string name;}
public class ItemContainer{public Item item;}
UXML:
BindableElement (no pre-set binding path)
-> Label (bindingPath: name)
Binding code:
public class ItemUI : EditorWindow{
public SerializedProperty serializedItem{get;set;}
...
rootVisualElement.Q<BindableElement>().BindProperty(serializedItem)
}
public class ItemContainerUI : EditorWindow{
public SerializedObject serializedItemContainer{get;set;}
private ItemUI itemUI;
...
itemUI.serializedItem = serializedItemContainer.FindProperty("item");
}
UnityEditor.UIElements.Debugger.MatchedRulesExtractor.<FindStyleSheets>g__RecursivePrintStyleSheetNames|4_0 (UnityEngine.UIElements.StyleSheet importedSheet,```
Have you ever encountered that error after opening UI Builder?
what is the best way to limit a flex direction from flex grow? I have a container I want to grow to the height of the elements in it, but not past that. Do I just alter the maxHeight property or is there another way?
also, if using flex grow, is there a way to limit the expansion to be a 1:1 ratio with the other axis?
oh, I guess I don't want to use flexGrow if I want it to be the size of the children?
Hi! Aside from the documentation, does anyone here have a resource they particularly enjoyed for getting started with UI Toolkit? Thank you.
Nope, and most info is lacking on it, in terms of specific examples
what would be the easiest way for me to rotate text so it is displayed vertically? And not vertically as in each letter wrapped on top of each other. Just rotate the entire textElement? Didn't know if there was something already implemented if so, and/or the name of this thing
just messing with label.style.rotate = new Rotate(-90); atm
I've been setting up some classes with properties that already exist on visual elements just to make my life easier reading through the IDE tips sometimes, anyways, I setup a property to look something like
public FlexDirection ContainerFlexDirection
{
get {return container.resolvedStyle.flexDirection;}
set {container.style.flexDirection = value;}
}
and made me wonder if any instance where I would want to read a value before the layout pass and that something like this won't work?
how do i get my text to appear on top?
In UIToolkit, the draw order is as
The top visual element.
The first child element of that visual element.
The child elements of the descendant element.
here are commands you can use that already exist
To change the drawing order of visual elements, use the following functions:
BringToFront()
SendToBack()
For sibling visual elements, use the following:PlaceBehind()
PlaceInFront()
changing an elements position to Absolute will also put the element on top, but, this changes many different other things also
Unity recommends not to use Absolute, unless using it as an "overlay" of sorts. Although I do agree with it, I also do love using absolute, but maybe not for good reasons. Absolute is what I use to essentially force an element in a position if I don't current know how to make that position work through relative hehe
any ideas?
Inline styles take priority over things like stylesheets... EXCEPT, when you use StyleKeyword.Null; I guess? Which results in me doing x.labelElement.style.minWidth = 0; instead of x.labelElement.style.minWidth = StyleKeyword.Null; or one of the other StyleKeywords since those work also. Any quick ideas on creating a basic VisualElement into things like my own TextField? I have an extension method for example, called ResetAll() that basically nulls out all default values set in a style so that I can better edit the native elements Unity has created, but, because of the above example, it just becomes a nuisance at times
I can also just disable that label element and make my own and add it as a child of the TextField container, but, that seems like a mess that although no one would notice, would still drive me nuts
hi all, have some one a hint for the best practice to show and hid a e.g. window or popup in Ui-Toolkit? Activate or Deactivate the UIDocument GameObeject or the the visibility of a VisualElement or something different?
Not sure about best practice, but afaik you can set the root visual element's Display style variable to Display.None. That should hide the whole panel.
I had some issues with this earlier, where some child text elements were showing up randomly despite the parent being set to Display.None. In that case setting the root element's opacity to 0 did the trick. Probably not the intended best practice though.
Is it possible to register a callback to trigger once a visual element is bound? need to update layout once I have the initial value and RegisterValueChangeCallback doesn't seem to fire on initial set.
.
For those who have any idea: How do you detect UI Toolkit elements with raycasts, like the Graphic Raycaster system in UGUI?
I'm trying to make an inventory system with a large visual element (an item pickup) that follows the cursor. Whenever the edge of this item pickup touches a visual element in the background (a 'slot') the slot needs to light up. The mouse isn't necessarily directly over the slot at that point though, which is why I need a raycast along points at the edge of the item pickup rect to detect the slot overlapping. Is this a valid approach, and how can you do this using UI Toolkit?
@hybrid galleon have you tried overlaps? https://docs.unity3d.com/Packages/com.unity.ui@1.0/api/UnityEngine.UIElements.VisualElement.html#UnityEngine_UIElements_VisualElement_Overlaps_Rect_
Hm, that could work. I'd have to have a pre-prepared list of the all the visual elements I need to check against, and loop through them all to check for overlap.
or you could subclass the VisualElement and override its Overlaps method.
public class Slot : VisualElement{
...
override Overlaps(Rect rect){
//light up
}
}
That works!
Thanks a lot for pointing out the docs reference
Is there anyway to get the SerializedProperty an IBindable is bound to?
Is there any reason if creating my own data containers for VisualElement things, that, I would benefit more from lets say, caching a float as a float vs just using StyleFloat
is there somewhere i can find the source code for UIElements' ListView?
i'm interested in where bindItem is called
ah thanks
I just realized I'm kinda confused between Auto and Null. If the value is null, isn't the default auto? For example, Align.Auto says
Let Flex decide.
But, if the value is Null... isn't that what it is already doing?
Null? When? Where?
Are you explicitly setting UIElements.Align to Null?
no, but, I do set it to StyleKeyword.Null instead of things like 0
if I dynamically change it
are the default values for IStyle set through the interface itself, or, the VisualElement? I'm trying to figure out if I wanted to have a clean IStyle if it would be easier to just set a new IStyle, or, to set all the values to StyleKeyword.Null
I guess I could inherit the Interface also, which would give it priority when the visual element does it's initialization right?
Then I could set all the values that way
does anyone know how NavigationSubmitEvent or NavigationCancelEvent work?
i want my own event to not have to manually load and enable an action map
how do I use a ListView?
I've got a this:
void onRenderPlayerInventory()
{
ListView InventoryList = rootElement.Q<ListView>("ItemsList");
Func<VisualElement> makeItem = () =>
{
VisualElement temp = new VisualElement();
Label itemName = new Label(); //add item name
itemName.AddToClassList("InventoryItem");
temp.Add(itemName);
return temp;
};
Action<VisualElement, int> bindItem = (e, i) =>
{
e.Q<Label>("InventoryItem").text = PlayerInventory.pInventory.inventory[i].name;
};
InventoryList = new ListView(PlayerInventory.pInventory.inventory, 32, makeItem, bindItem); //add element
InventoryList.AddToClassList("ItemsList");
}
but nothing is happening, and I can't add anything manually, either.
anyone ran into an issue where the UI Toolkit slider resets to 0 everytime you click on it?
- Just figured it out, the slider was moving outside of it's element box lol
I'm trying to reduce the amount of VisualElements I have being used for different things, and, instead doing something like
public enum ContainerOptions
{
None = 0,
Draggable = 1
}
for example, and, if an option is selected, to instead just alter different events one individual visual element is using. My question is, how I can approach this. I have Draggable draggable; for example as a separate field and set it with something like public void SetDraggable(bool isDraggable, DraggableOptions options = DraggableOptions.None), so that I'm not having the container double down? on events through the default actions and registering to them. Should I just have a method in my public class VisualContainer : VisualElement that adds to the default actions?
What about a Manipulator?
yeah, I was just reading more about manipulators, though I kinda scrapped what I was trying to do for now and just put all the draggable code into the main visual element and just toggling it
anyone know a way to force dark theme in UXML? I have a single editor with 15 tabs of information, don't really wanna redesign a whole new set of CSS for light-mode (at this time)
also, is there a better way to use a dropdown to navigate list items than how I've done it here (fake sort of binding)?
@pearl hamlet rw has a good tutorial that makes use of listView, he shares code too so you can just look at the end result by downloding project: https://www.raywenderlich.com/6452218-uielements-tutorial-for-unity-getting-started
Why does it not hide my menu when I set the root visual element visible to false?? It worked and then just randomly stopped working. How can I fix this??
hi, what is the correct way to handle TemplateContainers?
I am in the situation I need to add styles to template containers because they "broke" the styling
@latent inlet I understand TemplateContainers to basically be "your UXML File" yeah? What's wrong with yours that it needs to be restyled? (personally, I found dropdownfields came with a margin-left for some reason so have used USS to make those VERBOTEN!!!!)
Yeah, unfortunately IDK anything about the templateContainers. Since I do all my UIToolkit things specifically in C# I don't actually know anything about the UXML and USS files lol
In general though, I find TemplateContainers don't really have disruptive styling. They just behave a lot like one default VisualElement. So, curious what is making their thing break... or define "broke" lol (without referencing my bank account)
hmm, I tried replicating this with the following:
ListView list = rootElement.Q<ListView>("InventoryListView");
list.Clear();
foreach (InventoryItemInstance item in PlayerInventory.pInventory.inventory)
{
print(item.name);
VisualElement iRoot = new VisualElement();
iRoot.name = "Item";
Label iLabel = new Label(item.name);
iRoot.Add(iLabel);
list.Insert(list.childCount, iRoot);
print(list.childCount);
}
but list.Insert does nothing. childCount is still 0.
I believe ListViews are special in that they attempt to hide the many layers of complexity when you're using them
dig deeper into the hierarchy there. There should be a content box
for example, here is my full scrollview hierarchy
and even when i drag objects onto scr-standard-abilities it automatically dumps them into unity-content-container for me
i know list views are a little different though.... i think they have to be bound to a List<T> in order to work?
You're not intended to manually manage the children of a list view, it's done via the list view functions
maybe a ScrollView is what you're after lol, you can manually add to those
meanwhile... ListView is what I need.... ScrollViews are placeholder for now so i could visualize and prepare the childelements easier
A ListView requires setting the source, how you make items, how you bind them, and unbind them. Because it only shows what's on-screen and just rebinds items in its own internal pool
i cant add things to list view even this way
i am actually struggling to see from the tutorial i sent, where that binding is actually happening tho
have you looked over this? Didn't see this before, myself
https://docs.unity3d.com/ScriptReference/UIElements.ListView.html
Alternatively, you could also just do something like
void InitializeFoldout(string labelText)
{
foldout = new Foldout();
container.Add(foldout);
foldout.value = false;
foldout.text = labelText;
}
public void AddItem(VisualElement item)
{
foldout.Add(item);
}
and make your own list
little more complex than that, but yeah
Scroll view seems to be working fine for me (read: I can add items in the UI builder) but I want things to be able to be selectable
I have pored over this for 2 days and it still will not work
well. can I register a click event for a visualelement?
think so, yeah
yes, I can. That's good enough.
just tried with a red VisualElement in my CustomInspector
ve.RegisterCallback<ClickEvent>(TestClick, TrickleDown.TrickleDown);
works good
how exactly do templates work?
They're just a UXML tree that you can clone, creating that as Visual Elements
what is the status of ui-toolkits gamepad support?
@pearl hamlet I'm still new and figuring it out, but I am going with the full UXML/USS/CS worfklow and currently understand TemplateContainer to be just a regular old VisualElement, the only difference being that it's called "TemplateContainer". Unless you're asking LITERALLY how does it work, like "how is it implemented?"
in which case, here you can see my UXML/USS/CS file, for a custom inspector on my Test class
my uxml references the USS file and dropdown
in my editor script, i add my xml file to the inspectorGUI. VisualTree is the UXML asset itself, whereas my ui variable stores the TemplateContainer that comes from it, which is what the VisualTree becomes onces its inserted into the GUI
and BAM.... that's how you make a simple dropdown in only 5000 easy steps
#worthIt
so my next step is to create a Book system, where each book in the files is either
a) one UXML document that somehow has different Pages (which would be easier to work with) or
b) a set of Pages, each as UXML files (easier to implement I suspect)
and then these pages are then slotted into a general book screen that has page turning buttons.
How would I go about accomplishing this
can I add an entire UXML tree into a document from the script?
So you can load an entire UXML tree into a UI document?
yeah you can load millions in if u want
you can even clone the same UXML a zillion times
Huh. How do I do that? Just Add a VisualTreeAsset?
you can just run the above code snippet many many times lol
it will keep adding the same UXML, converting it to a TemplateContainer for your gui, and adding it to your UI
You can serialize a VisualTreeAsset, and call CloneTree on it, then you get a TemplateContainer, which is the VisualElement you can then use.
a) this will work, make a UXML and spawn it for as many books as you have. You will need some C# logic to populate its labels and buttons and stuff.
b) sounds doable
i mean... i SHOULDN'T... but i COULD.... do this:
or uh.....
Wanted to share that some new UI Toolkit packages have been uploaded to OpenUPM, some person made some dependency injection for making new components. https://openupm.com/packages/io.savolainen.uicomponents/
I don't know it looks cool and the guy doesn't seem to be getting much package traffic. Will be trying it out soon and maybe implementing a component for fun.
I feel like I might have been going through some of my custom UI all wrong... Not that it doesn't work, but, that, I could make my life easier. If I have public class VisualContainer : VisualElement what is the best way you think to go about "overriding" default style options? Originally, I was having things split into categories, and then set in the constructor. I didn't know if there was a better route? Some people got me thinking yesterday maybe I should just make a DefaulValues abstract class maybe, have it inherit from VisualElement, IStyle and then have my base custom container inherit from that?
Obviously I can inherit from IStyle in my base, but, I was thinking of this way to help alleviate the long list of IStyle interface that would show up
I was looking at using public new IStyle style; but, wasn't sure how I should go about setting the values in this way
I guess I could do something like this for the entirety of style
public class Borders
{
public StyleColor borderBottomColor = Color.black;
public StyleLength borderBottomLeftRadius = 0.0f;
public StyleLength borderBottomRightRadius = 0.0f;
public StyleFloat borderBottomWidth = 1.0f;
public StyleColor borderLeftColor = Color.black;
public StyleFloat borderLeftWidth = 1.0f;
public StyleColor borderRightColor = Color.black;
public StyleFloat borderRightWidth = 1.0f;
public StyleColor borderTopColor = Color.black;
public StyleLength borderTopLeftRadius = 0.0f;
public StyleLength borderTopRightRadius = 0.0f;
public StyleFloat borderTopWidth = 1.0f;
}
What's the equivalent to Repaint() in UI Toolkit? I tried using rootVisualElement.MarkDirtyRepaint(); but it's not working.
What exactly are you trying to do? A lot of UIToolkit changes take effect after the next frame, so, for example, if you change things in layout, and want to do something right after, people usually subscribe to GeometryChangedEvent. Not saying this is what you need, but, it's why I'm asking what you are trying to do exactly, since your question is usually asked out of relevancy with the above info.
can also look into using ChangeEvent
I want to redraw the editor after a button is hit.
sorry, that is still kinda broad... hehe, for example, Editor.Repaint is only for Use this method when you want to ensure that the inspector updates to show changes made in OnSceneGUI
I don't think there is a repaint that defaults the entire editor?
This is an Editor window that deletes a folder from a specified location. When I was using the legacy system, IMGUI, users would hit this button. It would delete the directory, and then the Repaint() function would redraw the window, and would from thereon only contain what folders were leftover (ie, would no longer have a button to delete prior directly).
My lead wants me to convert to UI TOolkit instead. mostly becase he wants only one system to be used. And I'm not as familiar with it. And MarkDirtyRepaint won't redraw it
have you tried having the button do AssetDatabase.Refresh();?
let me try
rather, after the deletion process, doing AssetDatabase.Refresh(); to be more specific
That did not refresh the Editor window unfortunately. The prior buttons remain
the buttons remain? If you want to remove a VisualElement, you have VisualElement.Remove VisualElement.RemoveAt VisualElement.RemoveFromClassList VisualElement.RemoveFromHierarchy
also, you have visiblity toggles for a pseudo visual removal, though, I prefer the style.display to this
that sounds like there's no equivalent to "Repaint" then - something that just redraws the Window GUI from scratch
is there an equivalent to window.Close?
I guess I might just be confused. I don't know how you can have a visual element removed without tellling it to be?
So this script reads through a directory of files. For each file it finds, it generates a button. Said button offers to delete that directory.
When I was using IMGUI, as soon as the user hit the "Delete this directory" button, it would delete teh directory and trigger Repaint(), and then the Window would flash, it would re-read the directory, and from there, for each remaining file it would draw a button.
Under UI Toolkit, however, I don't seem to have an option to Repaint() and recheck the elements
I'm going to try to Clear and then draw it again with a custom function
yeah, instead of repaint(), have the button do to delete the files, then an AssetDatabase.Refresh() then do VisualElement.Remove(this)
and THAT doesn't work either for some reason
when I say "this" what is it referring to ? The window?
IDK how you have your buttons displayed, but, this in reference to that specific visualelement
when I type in visual element. remove (this) it yields an error
if you are using the built in buttons, buttons are their own visual element
I am using just plain C# buttons
right, but are you using the UnityEngine.UIElements.Button?
I'm doing Button newBtn = new Button();
well, I'm going to assume yes then since you are doing it this way. try .Remove(newBTN);
I'll type out something really fast to double check
and then I set it's text with newBtn.text = " My name";
And then I assign it's callback function with newBtn.clicked += () => CustomFunction(parameter);
how do I remove the btn from it's callback function?
so, to give an example, I have a class called
public class VisualContainer : VisualElement
in it I do this.Remove(exampleBTN); to remove the button, or just Remove(exampleBTN);
that would mean I'd have to cache each newBtn somehow
because the delete command need sto come from the callback function
have you tried just doing doing -=?
no, I do that, but, you don't need to do that. That is what Query is for
so again sam eissue- the callback function has no idea which button it's attached too. How can it unsubscribe?
not sure how to do that
well, you said the button deletes a file in the directory. You could just make the .name equal to that file
VisualElement.name
So then I can name the button. Something like Button newBtn = new Button() { name = "foo"} and then I can do a rootVisualElement.Remove("foo"); ?
yes, alternatively, you subscribe the button to events that just do this itself, so, in the event, do something like, parent.Remove(this):
then you don't have to name it
since you won't have to find it
Unfortunately when I try to write rootVisualElement.Remove("buttonName"); that does not work - it produces an error
what is the error?
Says it cannot convert a string to UIElements.VisualElement
oh, that's because you can't convert it that way lol. The point of naming the element was to be able to pin point the visual element by name
not to use it in that way
so, for example
that means cache the Button as a variable at the top of the script right?
no, because you can use Query commands and do something like this.Remove(this.Query<VisualElement>("Name"));
if you don't want to cache
this is not needed, I just default to typing that out sometimes
that was on a parent element
but, what I would try first, is doing this, hold on let me type it out
so, basically, this
void Testing()
{
exampleBTN.RegisterCallback<ClickEvent>(OnClick);
}
void OnClick(ClickEvent e)
{
// Delete Asset
UnityEditor.AssetDatabase.Refresh();
Remove((VisualElement)e.target);
}
man this is so complicated compared to IMGUI. I wish I knew why my lead was so insistent everything go to Toolkit....
Probably to do with organization. Well, among many other things, but, the fact that you don't need to clutter up a scene with UI objects is huge for some people
this isn't a scene. Its just an Editor window to delete a custom package cache the devs don't want to spend two minutes looking for
it doesn't face an actual app user ever
hmm well idk for sure, however, I can say that making UI inside the editor and game has been incredibly easy since using UIToolkit, and, also, I know that one day, from my understanding, Unity will transition all of its UI over to UIToolkit
if you look at the debugger, much of Unity is already inside of some sort of UIToolkit feature
I see. So this is coming anyway then
yeah.. that checks out. It's Unity after all π
PFFFT so I followed your code - it just clones the button
nope nevermind - it literally clones the entire window a second time
that's so silly...
hmmm
that's odd, since it should only remove the visualelement target
wondering if UnityEditor.AssetDatabase.Refresh() is causing it to refresh your UI along with the database, sorry, I'll try to wait and see if someone a little more experienced steps in here. I just know this channel is usually quite, so, trying to help hehe
No probs! I appreciate all your help as it was π Thank you
It seems stupid to convert a functioning window to a UI system you're not familiar with
The lead sounds pretty foolish in this regard
I'm regards to Unity transitioning to UITK for the editor, the default inspector UI is now UITK, but of course there's still a ton of nested IMGUI. I would imagine it's going to stay like this for a very very long time
is UI toolkit considered production ready in unity 2021.3?
If you mean for runtime, I would say no. There are large limitations that you will run into if you need to do anything mildly interesting.
It does have its own strengths, but currently there's a ton missing https://docs.unity3d.com/Manual/UI-system-compare.html#feature-comparison-ui-toolkit-vs-unity-ui-ugui
i am tired of making riddles with UI like this
and designer made prototypes in figma, there is bunch of CSS for rounded corners and stuff that are missing here
well, that UI is certainly doable, and easier in UITK
maybe not if you consider that amount of groups, width of items and slots is dynamic based on scriptableobject data
and layout of bottom answers is custom code as drag & drop plugin doesnt play nicely with layout groups
π€· all of that is doable. It falls apart if you want to add custom shaders, or rich text (I thought it was supported, the docs say otherwise), complex masking, world-space interactions, etc.
Layout is a strength of UITK, but it may require a custom setup, which is hard if you're not familiar with it
You could just experiment with dragging and dropping something together in the UIBuilder to see if you run into issues immediately
I'm trying to get a VisualElement to follow the mouse for an inventory system, but there always seems to be a one-frame delay in adjusting the position. The item icon's centre is snapped to the mouse position each Update like so:
{
Vector2 mousePosition = Input.mousePosition;
Vector2 pos = new Vector2(mousePosition.x, Screen.height - mousePosition.y); //inverted
icon.style.position = Position.Absolute;
icon.style.left = pos.x - sizeoffset.x;
icon.style.top = pos.y - sizeoffset.y;
}```
But if you move the mouse fast and take a screenshot shot, it can be 100-200 pixels off
Just to say that the docs page is shall we say... on the cautious side of what's possible. I don't even know when they last updated it. Rendering UI to RenderTextures works really well and thus allows you to do pretty much anything. I've used it on a curved world space mesh in VR. Rich text is somewhat supported but not perfect (2022 has better support I believe but we're on 2021). You can't use custom shaders but you can render most things to a RT and put that in the UI if you want. Here's a screenshot showing multiple UI Docs working with 3D content, blurred layers, custom shaders for colour picking etc etc.
Biggest flag I'd raise is a year of scroll wheel speed being way too slow and basically no way to fix it π€¦ββοΈ. That and other bug fixes which are taking an incredibly long time to come to 2021.
Probably a good idea not to use layout... if you're on >= 2021.2 they introduced transform styles: https://forum.unity.com/threads/introducing-transform-styles.1195972/
VisualElement.style.translate = new Translate(1,1,0));
Ah, this is exactly what I needed. Thanks a whole bunch!
A lot of my Discord chums have said the same thing. That since it's Editor only, and not doing anything special, there was no reason to convert.
But if everything is moving to UI Toolkit, this was a good notice to start becoming familiar with it (Unity Learn - Here I come!)
as someone that is only a singular in my projects atm, I can see both sides. Just create an AI instead that does both... π
lmao. I'll learn the toolkit
it was just a bit inopportune for him to wedge that in there on a deadline
especially since he isn't overhauling the older stuff yet either
I have been only using pointer events in an effort to apply to basically everything, including mouse, however, I am noticing some uhhh, funky things? Is not taking into account mouse also possibly screwing me up?
For example, here is some code I have for displaying a selected VisualElement,
if (evt.eventTypeId == PointerUpEvent.TypeId())
{
if (borders == null) borders = new Borders();
borders.SetBorderData(resolvedStyle);
if (selectedVisualContainer != null) selectedVisualContainer.borders.SetVisualElementTarget(selectedVisualContainer);
selectedVisualContainer = this;
selectedVisualContainer.BordersWidth(2.0f);
selectedVisualContainer.BordersColor(Color.red);
this.ReleasePointer(PointerId.mousePointerId);
}
works great! However, when I move an element, it sometimes doesn't do the appropriate behaviour, though with a debug I notice all the events are still firing, let me see if I can get a quick screen record of it
this is my field for the selectedVisualContainer
static VisualContainer selectedVisualContainer;
Maybe I'm running into a problem with things happening at the same time? Should I create a property or a method with a lock or something?
maybe a delegate hmm
okay, I think I figured I out.
I'm doing
if (selectedVisualContainer != this) borders.SetBorderData(resolvedStyle);
now. I think what was going on was I was saving previous border data so that I could switch it back to whatever the borders were before, so, i was actually resaving the border data with the selected border data. This change solves this. Alternatively, I guess I could just make a selected visual element overlay, however, I still don't know which is better? If to make a visual element for literally every little thing, or to just changes to a singular visual element
The benefit to using a separate visual element is when you add things like textures and stuff, things become a little more complex, where as a new visual element prevents any altering of the original. So for ease, I understand that. I'm more wondering for performance
so now I'm trying out something like
if (evt.eventTypeId == PointerOverEvent.TypeId())
{
hover.style.display = DisplayStyle.Flex;
}
if (evt.eventTypeId == PointerOutEvent.TypeId())
{
hover.style.display = DisplayStyle.None;
}
my question is, if I disable picking mode on an element, can I still subscribe it back to pointer over and out events? Then I can leave this inside the hover visual element specifically
why is the resolved style for things like flexBasis StyleFloat, and not StyleLength? Or, viceversa
same with why is things like height and width resolved just float, instead of StyleLength? It's very inconsistent. Not even that it's that, but the fact that there is so many values that fall under StyleLength in IStyle, that then not only don't fall under that in ResolvedStyle, but seem to resolve between StyleLength, StyleFloat, and just float
Hello, is there any way to obtain a recently instantiated visual element width? My code is something like this:
uiTooltip = Addressables.InstantiateAsync(TooltipType.HUDTooltip.ToString()).WaitForCompletion();
VisualElement root = uiTooltip.GetComponentInChildren<UIDocument>().rootVisualElement;
Debug.Log($"layout width: {root.layout.width}");
This gives me NaN even with root.layout.max.x or layout.xMax.
I also tried with a RegisterCallback<GeometryChangedEvent> printing the event.newRect....x but this gives me 1920 (The maximum current screen size)
Any suggestion?
I believe that the layout engine takes a frame to arrange everything after instantiation - so if you check the layout properties like width immediately after instantiation, you'll get an uninitialised value i.e NaN.
The 1920 seems to be the width of the root visual element. When you make a new UI Document, the root element is afaik an empty parent to which all the other visible visual elements are childed.
So in the geometry changed callback, perhaps you can query a specific child element by name and test the width of that.
I remember disabling picking mode on an element and still getting pointer enter and exit events (which were undesirable for me) - so it looks like you can do that.
I used a separate visual element for highlighting borders, personally. Since there's only one selected object at a time, i just had one pooled 'border highlight' element set to Position.Absolute, and adjusted its rect position and size to that of the currently selected object.
Using a simple object pooling system, that can be extended to highlight n number of visual elements at the same time, without having to have one border element overlay for every selectable visual element.
But this seems to be the nicer way of doing it
I can't seem to figure out how to open the UI editor....
I thought there was a UI windows to dragging things to the right place.
Oh well. Time to get to work and figure this out later today.
hiya, trying to figure out how to log the button I just clicked
closest thing i can see that might have anything to do with that might be e.target but that seems to return IEventHandler not VisualElement and there don't seem to be any properties of it that can help me here.
I might have asked this before... but does !important not work in USS?
or uh... is there any way to give your USS class priority? It keeps getting overridden by the built-in defaults ; ;
weird..... think i just discovered that USS selectors are applied in a different order depending on their... alphabetical make-up???? 0_o
when i simply make a selector for .selected in my USS, it gets positioned second, and overridden by the following 2 selectors
But when i select instead via .menu-generic > .selected it now has priority and is ordered last.... why is this?????? There really is no !important to solve this?
I am trying to become better acquainted with UXML, and I'm noticing my IDE isn't playing so nicely with it. Is there a setup or plugin I should consider? I have both VS Code and VS 2019. Either will do.
The only IDE I've seen that has official support for UXML and USS so far is Rider
VS not too good with it
and VSCode.... i set VSCode to interpret them as XML and CSS, and that's working ok for me so far
to clarify how you use this, is you cast that target as a VisualElement, for example, (VisualElement)e.target
in general, to get the specifics I guess you could say of an event, you do that for everything. Such as protected override void ExecuteDefaultAction(EventBase evt) I do PointerMoveEvent e = evt as PointerMoveEvent; for certain specific things I want under the PointerMoveEvent also
Thank you! You completely solved my problem π
do you mean UI builder? I think you can double-click any UXML file in the editor to open it in UI builder.
Or else open it from the menu Window > UI > UI Builder
Hello there, any tip on how to resize a progress-bar to be smaller? I tried almost everything and cant achieve it.
I did try creating a custom uss class called .unity-progress-bar and overriding the selectors at the root progress bar element but still showing a default bar at playmode :c
Do anyone knows how to do this the proper way?
EDIT: I want to reduce it's height btw, I can increase or decrease width size without problem, but can't resize it's height to be smaller somehow
I managed to achieve this modifying the transform.scale.y from the ui editor ππΌ
oh ty so much, i'll try this later
that's awesome. Man, documentation on this stuff is abysmal.
hi, I need some help to understand the logic to handle the "selection" of different components in a game menu.
the EventSystem has the SetSelectedGameObject method, but I cannot pass it a VisualElemenet (component)
maybe I should create a gameobject for each component in the menu?
at the moment each component is a template that is imported into the game menu view
how it is supposed to work UI Navigation in UIToolkit?
@latent inlet I'm new to these, but why use EventSystem to get the selected VisualElement? I would have thought registering a callback to the element to log itself when clicked would be the way to go.
my own question: I asked on Unity Forums how to force dark mode, only answer is from a Unity rep telling me "you should support light mode". Aside from the fact that I'm none the wiser as to how to force dark mode... does anyone happen to know how to provide light and dark styles? Is there a UXML tag to support alternative USS sheets? or some variable I can check in C# like Editor.isDarkMode or something so I can manually swap out stylesheets in code after checking this?
ie. is there some way I'm able to check Preferences in C#?
I unfortunately only do most my stuff within my own C# code, so, don't know much about doing things with a sheet, however, if you do it this route, from my most simplistic way to handle something like this, I would probably just alter style.backgroundColor between black and white colors, and then some sort of altering possible between style.Color for the text color, and/or style.unityTextOutlineColor, style.unityTextOutlineWidth
if you alter just the outline, you possible don't need to worry about style.Color at all
hm, my editor is large and complex lol
it would be a lot of elements to manipulate individual styles on directly in C#
yeah, I should have been more clear, if you know how to alter those fields in a sheet, editing those might be the values you would edit for a light/dark mode toggle
i think where im stuck is not so much what to change, but how to know if the user is in dark-mode or light-mode
i cant really alter anything unless there is some way i can tell
oh, gotcha, is this for the editor, or for in game?
just for editor
UIElements is pretty cool after dealing with IMGUI for so long lol, but man I wish it had closer parity with HTML/CSS. There are a few things it really hits a brick-wall on at this stage lol
I actually would have no issue currently if I just used default theme styles for everything, but my UX would suffer as a consequence, need those custom colors in background for readability, but the second I do, it works great for dark-mode but terribly for light-mode
I'm trying to figure out more about "themesheets" but not having any luck, so far
ah dont worry lol, dont wanna chew up your time on it haha, ive dug around a bit already, doesn't seem like optional stylesheets, mediaQueries, or a theme-check in C# exist at the moment lol. I have a topic open in Unity Forum so hopefully that grabs some attention
my editor looks like complete @$$ in light-mode ^^;
heres something I finally found so far, not much, but hoping it can send me down some rabbit hole m_SharedStylesAndDocumentElement.pseudoStates |= PseudoStates.Root; // To apply variables of the active theme that are defined in the :root selector
I would like to rely on ui navigation events because it's ui-related and it works out of the box with new input system
innnteresting
okay, I knew I remembered somewhere how, but couldn't remember, however, I think this is what you want to check EditorGUIUtility.isProSkin
there is more complex skin checks, I just don't remember all of them atm, let me see if I can find them
no need, that's perfect, ty, it works
oh okay! Only reason I mentioned it is IDK if this specifically lets you check if light or dark. IIRC is is pretty convoluted, as in, you need to get the IDs for them, and then you have to check that specific ID or something
oh wow haha, sounds heavy. Well, for now, this is great, I can start adding conditions to the start of each of my editor scripts
I use to have a list somewhere that had a lot of the the native IDs for different things in Unity lol, but can't find it right now. For example, all the IDs needed to do something like changing the cursor to a specific icon
first I've heard of em, that's made handy tho
yeah, I've been creating custom icon scriptable objects thing through UIToolkit, so happened to come across them in the process. It is kinda annoying though, because like, Unity has like 100 different versions of some icons lol, so scrolling through the list is just annoying
Hi guys ! I'm trying to create my own VisualElement to create a tab system
Is it possible to create a new EventBase to have my own callback that work with my tabs?
I haven't messed around with the EventBase itself, so, not 100% sure on that. I know you can just do your own delegates. That all being said, I also know this could be of some interest to you https://docs.unity3d.com/2022.2/Documentation/Manual/UIE-create-tabbed-menu-for-runtime.html
Okay thank-you ! Interresting, i didn't see it but what i'm making looks quite similar. I have thought about using my own delegates but i thought it would be "cleaner" if i could implement it in a way that you wouldn't even notice it's not smth built-in haha
I use my own delegates all the time because I haven't perfected my knowledge yet of the entire event system hehe, that being said, you can prevent a visual element completely from doing any of it's default actions and do everything through your own delegates if you really want hehe
Actually i think i need only a way to dispatch that a tab has been switched and it will be enough π
I'm going to try and explain this without a screen record, but, I'm trying to think about how to best approach allowing an element to be adjustable that is a relative position, without necessarily having any impact on the other siblings. I'm struggling to find a route to go, so, had a couple directions I was thinking about going and could use some advice? One was to make an invisible element that basically takes the current place of the element being altered and then making the element just absolute position. The other was to make it absolute, but then alter the padding and such of the other elements to pretend there is that element still there.
the other thing I was considering was just possible scrapping using relative on basically all my visualelements and just using absolute on everything
does changing variables of VisualElement.style actually do anything or is it only meant to access values for inline styles?
nvm, seems i was just changing style variables on the wrong visual element
What's the use case?
Nothing specific atm. I'm reducing some of my visual elements and instead created 1 called public class Interactive : VisualElement with things like
public enum InteractiveOptions
{
None = 0,
Draggable = 1,
Expandable = 2,
Hoverable = 4,
Selectable = 8,
All = Draggable | Expandable | Hoverable | Selectable
}
so, was looking for a catch all, well, better than what I already had setup. In my original Expand visual element I was checking vs every different alignment and stuff in a parent element and having the visual element adjust, but, was looking for maybe a more simplistic approach
There are Transform styles where you can scale an element without affecting siblings afaik: https://forum.unity.com/threads/introducing-transform-styles.1195972/
Someone on this thread just brought them to my notice actually
yeah, I use translate a lot, but, I assumed that scale was like actual Transform scale, same with rotate, so haven't actually checked if I could use those to my advantage haha
do you guys have a better naming system or something I could use in case of
public enum AlignmentOptions
{
TopLeft,
TopCenter,
TopRight,
CenterLeft,
Center,
CenterRight,
BottomLeft,
BottomCenter,
BottomRight
}
IDK, I'm just not liking it this way. I was thinking about calling it Anchor instead?
because the overload of Button is not accepting a string to name it. You need to do new Button() {name = "Button_LogIn", text = "Log In"};
no I meant like
referencing it
I made it in UIBuilder
and I couldn't reference it using Query
so I had to create it like this for some reason-
you do actually have a name in here and saved uxml?
I guess?
ok now it works-
maybe it just got deleted
I do have another question tho
I have multiple menus I wanna cycle through, and when I make one invisible and the other visible, it looks like this~
I obviously can't say for sure, but, it might fall under the same principle as when a Unity restart fixes a problem you are having. Possibly just something wasn't updating correctly, and then it was fixed
yeah
I'm not sure how you are dealing with your visibility, but, there is a couple routes you can go. I typically choose this route style.display to DisplayStyle.None for invisible and DisplayStyle.Flex for visible. From my understanding, and a little experience, this will make other elements flex correctly like the element isn't there, but, will leave the element in the hierarchy still
IDK if it ever got fixed, but, that uses the style.visible instead of display, and, from my understanding last I checked, was causing people headaches
IDK if it ever got "fixed" or made better
well, thanks for the help!
Is there a way with relative position to do a JustifySelf?
I can't get Visual Studio 2019 use/recognize the UI Toolkit. In Unity I already selected Visual Studio 2019 as the C# editor and did the "regenerate project files".
hmm what am I messing up here? I have 1 visual element with flexGrow set to 1.0f, and one with it set to 3.0f, but they are both still doing a 50/50 share
nvm, I think I figured it out, but, not sure what value to set at. The child element was with flexGrow 1.0f was causing it ti still take up half, but, it confuses me, because I thought sibling flexGrows were taken into account when flexing also? I mean, it is, but like, idk
I recently upgraded my editor version from 2020.3.26f1 to 2021.3.2f1. Along with that came an update to the UI Toolkit. I have a scene that uses UI Toolkit to display a button with a clicked event for displaying a UI menu. In addition, I had implemented swiping detection for other game objects in the scene. These swipe events require an EventSystem be present in order for the events to register. Since the upgrade, the UI Toolkit clicked event does not work unless I remove the EventSystem object from the scene, but then the swipe events do not work.
I just realized that a PanelRayCaster component gets added as a child to the EventSystem in the hierarchy when running the project, and if I disable that component, then both the swipes and the UI Toolkit clicks work as they did before the editor upgrade. So I've added this code to my scene, and now I'm just wondering if there will be unexpected (undesired) behavior down the line because of this:
var es = FindObjectOfType<EventSystem>();
es.gameObject.GetComponentInChildren<PanelRaycaster>().enabled = false;
If whatever you are doing works without it, unless you have something that has reliance on this specific thing, there shouldn't be?
Does anyone have any familiarity with FlexBasis? I'm thinking it might be something I need to tweak to give me more accuracy, but, I haven't really messed with it at all. I'm having a problem that some of my flexing doesn't seem to be flexing with same settings that I have on elements in the yoga playground
I've only debug checked the values of a default VisualElement style though, maybe I need to check if something is different in the TextElement default style values that are causing me a problem
Hey, I create a simple layout using UI Builder, and I've queried a VisualElement that I have, and in code, I want to get its Rect and render using IMGUI.
The problem I am having is the Rect I get from the VisualElement seems to be off, the width and height seem to be correct but the x and y seems to have an offset, any idea why?
I am using worldBound by the way to get the rect
I haven't used worldBound, so idk if it does anything different, but, the default pivot iirc for Visual Elements is the top left corner. So, the width measurement should return values to you from left - right, low - high, and the height is top - botton, low - high
How do I get the top left corner if I use flex?
.style.left should be 0 (I assume)
there are 4 Rect's in VisualElement 3 of which in local space, and the only one in world space is the worldBound, I'll try to debug and see if I can find where the proper values are stored
in the case of flex, you shouldn't be reading values from style, only using style to change values. You should be reading values from resolvedStyle
also note that resolvedStyle changes take a frame to update
Cool, didn't know about that
well, tbh, I still don't fully understand whats happening between style > resolvedStyle, but, it is just how I do it.
Got you, trying it right now, if it does take a frame to update it shouldn't be that bad, I could delay my render by one frame also I assume
It seems like worldBound contain the same values as resolvedStyle
Here is an example though for style and resolvedStyle. I'm wanting the values for alignContent and alignItems. The first 2 debugs are from style, the second 2 are from resolvedStyle. The only reason the second one isn't showing up as a null from this debug is because I am directly setting style.alignItems = Align.Stretch; in the code before it. In this case, you CAN read from style for immediate accurate results
but if you are using Style Sheets, you basically need to rely on resolved style if that is where you are making most of your changes
That make since, I seem to be getting the right values but there is a slight offset, and it seems like resolvedStyle (Checked all its properties) contain the same values that I use
So it seems to me its something to do with the layout itself maybe
Or stupid me doing something wrong
oh, my comments are mostly... uhh if dealing with flex, I find more success in checking Resolved Style for things. In terms of your question and sorry about the long route, the pivot should always be the top left. I'm not entirely sure how to actually change that, however, you can use transformOrigin style to possible offset positioning if there is a different pivot? Besides that though, I usually use translate to offset already assuming top left
.style.Left does different things depending on if your VisualElement is absolute or relative
Yeah I know that, the pivot position is not my problem, I'll attach an image and try to explain
I have a simple setup using VisualElements, you can see the grey ones, and there is a transparent one in the center (where the white rect is, which is rendered in IMGUI).
You can see that the rendered rect, that uses worldBound, has an offset, I tried using the values from resolvedStyle but they are getting me the same rect
GUI.DrawTexture(_centerElement.worldBound, EditorGUIUtility.whiteTexture);
This is my draw call from OnGUI
Actually it seems to have an offset in y exactly the amount of the EditorWindow title
I think so at least
But, why are you trying to mix IMGUI and UIToolkit this way?
Maybe not, anyway I am not sure where I am wrong with my offsets, I didn't apply anything on my end just took it from the VisualElement
I want to render a texture that I manipulate
have you tried to just use IMGUIContainer and then you can use UIToolkit things to auto layout it, or make it absolute and for it to stick to lets say the top most part of the UI
Haven't tried IMGUIContainer actually, I'll read up on that
what I mean is, doing it the way you are doing requires more mathematical calculations to display things appropriately
Only reason I brought it up was that if you use that Container, you may not even need to account for an offset
I don't have any personal experience with IMGUIContainer itself, but, I do mess with custom textures with style.BackgroundImage and know you don't need to use IMGUI
That might work
I have a few things I need like repeating the texture and manipulating the UV, I'll need to check if I can do it in the way you suggest
wish I could help more with this, but, my dynamic textures only consist of the textures I have in a color picker atm hehe
Lol
You helped a lot!
thanks!
IMGUIContainer really seems to be lacking examples
Oh but I found an article, basically he inherit from IMGUIContainer and register a function to onGUIHandler, the only thing left is figuring out how to properly create my custom IMGUIContainer (there is a IMGUI Container option in the Library inside UI Builder, but I am not sure how to use it)
Ok, created it in CreateGUI and it works perfectly! the worldBound now has the right values!
FlexShrink still confuses me. I'm not sure why removing it off any element fixed some of my flexing problem
I think part of my problem and something I need to maybe get better at is, if I flex a child element, I don't need to set the flex on the parent?
I think that the parent wont use the flex system but its child will
hmm nvm, I think I finally figured it out. Still not sure why yoga playground gives different results with same settings, but, if I do my weight on 1 element with flexGrow = 1.0f, and another as 3.0f, if I set the flexShrink to 3.0f on the first element, I get the accurate flexing I'm looking for
what layout are you trying to achieve?
creating my own Vector3 display. Ignore the borders, I set them all when I'm editing UI elements to help me see layout easier
Cool, I read this the other day, might help:
https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox#flexible_sizing_of_flex_items
(Talking about grow and shrink)
I'm trying to figure out why this happens? I have things like flexWrap set to no wrap etc..
Can you show your hierarchy?
TextElement.isElided might be what I need to mess with let me see
not really, I do all my UIToolkit in c# and haven't finished a nice way of displaying that yet
Oh okay, thought you are using UI Builder
okay, I found the correct thing to edit style.whiteSpace = WhiteSpace.NoWrap;
which is confusing
not in terms of what it does
but the wording used along with other properties
Hello, is there a "not" operator in uss ? Like I have a hover state on all my btns but I dont want the hover state if the button also have the active class
Am I doing this right?
anyone can help me? i placed a button in my canvas, with the functions of i need, but i cant press the button
i'm trying to click, but without success
Maybe the button is blocked by other elements btw this channel is about the new ui-toolkit stuff, #π²βui-ux would be better
hey I noticed shader support is still unfinished for UI Toolkit, I was wondering if it's possible to embed a canvas for a hybrid approach
Hello! I'm in a conundrum coming over from uGUI to UI Toolkit.
On the Right is my uGUI Canvas with buttons, using the same 9-slices as on the Left, which is in UI Toolkit.
I don't have, from what I can tell, the ability to scale the pixels per unit in UI Toolkit like I can in uGUI.
So my sprites are doing some stretch-y weirdness on the UI Toolkit.
Use the slice settings in the style
They just warp the sprite. They don't seem to scale it.
Any ideas why unity is spamming these error when I'm moving the UI elements (inside UI Builder window) or doing almost anything else?
I know this might sound silly, but, why are things named AlignItems and JustifyContent? Why isn't it just called CrossAxis and MainAxis?
like, I understand that the goal was to imitate the current web flexbox, but, seems odd to me to not make it better. Would make more sense to just have AlignMainAxis, AlignCrossAxis, and stuff like that, idk, I just find it weird I guess, not that it doesn't work.
is there a way to do something like Align.SpaceBetween with a fixed number?
I'm trying to make a default value of space between visual elements in a list, maybe I can just have the list edit the childs margin when it's added?
I guess I could also uhhh increase the height of the list and use SpaceEvenly, but, hmm
oh nvm we don't have a SpaceEvenly
Anyone have any best-practices for modifying integers with a dropdown?
I have a database with a few lists in it, but i never cache these in my codebase, ever, instead i expose methods to grab list-elements by index, and in my custom-inspectors, i read from the list to populate dropdown names, but i use this to customize a "selected index" integer.
So the problem I have is that there are tonnes of best-practices floating around for UI-Toolkit about working with SerializedProperties to automate SetDirty() and Undo/Redo. But I'm not able to bind paths from a dropdown to an integer, instead I am manually updating and applying modifications to serializedObject everytime my dropdown changes, and in 2 other instances if my Dropdown has to refresh its options when the core list updates.
in short.... how would YOU best-manage SetDirty/ApplyModifications etc. in UIToolkit when you are manipulating an integer using a dropdown that sources its choices from names in a list of objects?
IDK if this is best, but, this is what I ended up settling on for my question for now
public void AddItem(VisualElement item)
{
foldout.Add(item);
item.style.marginBottom = 10.0f;
}
ah, you mean you'd suggest a foldout instead of dropdown?
oh, that was just to add to my above question, sorry
allg ^^
to describe a use-case for my dropdown... selecting enemies. I have this list of enemies
and a custom inspector capable of browsing that list and assigning it to my MonoBehaviour as an integer
the way I would personally handle the setdirty, is make an extensionmethod to the visual element with an Object param
this may be bad form, but I'd appreciate anyone looking over this to point out anything obviously stupid that I'm doing here
[CustomEditor(typeof(Test))]
public class CustomTest : Editor {
private TemplateContainer ui;
private DropdownField ddfEnemySelect;
private SerializedProperty _iEnemy;
private void OnEnable() {
_iEnemy = serializedObject.FindProperty("iEnemy");
}
public override VisualElement CreateInspectorGUI() {
serializedObject.Update();
VisualElement root = new VisualElement();
VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Test/Resources/UXML/EditorTest.uxml");
ui = visualTree.CloneTree();
root.Add(ui);
GetControls();
InitializeDropdown();
return root;
}
private void InitializeDropdown() {
RefreshNames();
ClampEnemyIndex();
ddfEnemySelect.RegisterValueChangedCallback(_e => {
Debug.Log((VisualElement)_e.currentTarget);
_iEnemy.intValue = ddfEnemySelect.index - 1;
serializedObject.ApplyModifiedProperties();
});
Debug.Log(_iEnemy.intValue);
}
private void GetControls() {
ddfEnemySelect = ui.Q<DropdownField>("drp-enemy");
}
// Get names from my list again, in-case the list has changed. Rename empty objects, update index.
private void RefreshNames() {
List<string> names = DBResources.GetEnemies.enemyList.Select(x => x.name).ToList();
names.Insert(0, "-");
for (int i = 0; i < names.Count; i++) {
if (string.IsNullOrEmpty(names[i])) {
names[i] = "UNNAMED";
}
}
ddfEnemySelect.choices = names;
ddfEnemySelect.index = _iEnemy.intValue + 1;
}
}
couldn't fit the last method in
private void ClampEnemyIndex() {
if (_iEnemy.intValue >= DBResources.GetEnemies.enemyList.Count) {
Debug.Log($"(>=) {_iEnemy.intValue}");
_iEnemy.intValue = DBResources.GetEnemies.enemyList.Count - 1;
serializedObject.ApplyModifiedProperties();
}
if (_iEnemy.intValue < 0) {
Debug.Log($"(<0) {_iEnemy.intValue}");
_iEnemy.intValue = -1;
serializedObject.ApplyModifiedProperties();
}
}
this is basically my test script im using to get better at UIElements before i proceed any further
hm... i'm imagining how I might go about that, yeah, structure-wise and executing it nicely in my front-end... could give it a go
ignore the bizarre -1 and +1 stuff floating around with my index there, it's a countermeasure after faking a null option into my dropdown choices which provides a -1 index later
let me try and give an example. I'm currently messing with some stuff, so I'm actually not 100% sure if this works atm, but, you would do something like
#if UNITY_EDITOR
public static void UpdateObjectFromVisualElement(this VisualElement target, Object ob)
{
UnityEditor.EditorUtility.SetDirty(ob);
}
#endif
then, on your dropdown events for example, when the the value changes, you call this with the target object
yeah, I see, smooth, I like it
wish i could just bind a dropdown to an integer lol, why string is only option ; ;
need 2-way binding like in angular and react
i'll have a go at adding the extension method later, couldn't resist planning out my evening while im still at work lol
I'm also looking at making my own Dropdown class that connects itself to a list that I can just modularly distribute across my many custom editors, so extension methods will definitely become a valuable part of the system here.
Yeah, I already tried to take advantage of extension methods for many things, but I've even converted some of my custom uitoolkit stuff into just extension methods lately
nice
I'm still at a stage where extension methods don't naturally occur to me like other structural ideas do lol
I have been making my own things personally instead of using Unitys for stuff like Dropdown. IMO, and it may just be me and overthinking, but, they just make it so hard it feels like to customize any of there things, and excessively limit things you might want to actually edit through private protected internal keywords
usually takes someone else pointing out obvious ideal cases for them lol
yeah totally. Like would I be better off creating my own Dropdown system out of raw VisualElements, and my own ListView cos theirs' is a proper bastard to work with
scraped my brain on how to use their listView and their documentation has an example buried in there somewhere and they cover a lot of the complex thing their ListView does, meanwhile i'm beating my head against the screen saying "HOW... DO... I... CONNECT... MY... LIST... TO... THE ... LISTVIEW?"
(I've figured it out now, s'algud, but the experience of learning how was nuts (documentation is also a bit better now))
in my above code snippets, would you say my 3 uses of serializedObject.ApplyModifiedProperties(); for the one piece of UI is excessive? Or is that a normal situation to have?
coming from IMGUI, I just have one EditorGUIUtility.BeginChangeCheck() at the start of my editor window, and at the end I just put
if (EditorGUIUtility.EndChangeCheck()) {
so.SetDirty();
}
which unfortunately seems more elegant by comparison. So I was wondering if I was being a bit crazy with how often I'm repeating serializedObject.ApplyModifiedProperties(); here, and for just one control, imagine when I have many more (it will still be multiple calls, even when I use extension method).
Is there no sortof... event or callback i can use within a Custom Inspector that can respond to UIElements changes?
IDK for sure, however, I would always try to reduce redundancy if you can, anywhere. If you are calling serializedObject.ApplyModifiedProperties(); 3 times for the same object, chances are you can make changes somewhere
I haven't done anything with that in a while, but, from what I can remember, I use to just throw that in at basically the end of everything
yeah, it was capable of tracking your entire GUILayout with a single call, which was super handy. Basically only needs to clamp start and end of your editor window and job done
i know it'd be a fool's errand to pursue parity between IMGUI and UIElements cos they are different beasts, so probably some of my clumsiness right now is just growing pains as I move away from IMGUI
it was ultimately USS that won me over lol
hehe, IDK if it is or not. I was trying to find a way to create my own UI system all together, but, not enough experience or know where to really start, so am basically building backwards... which doesn't sound fun, but it is fun for me hehe, but, basically, to an earlier thing we talked about, for UIToolkit, I use a lot of Unitys things, but, as placeholders essentially. Then slowly break it down into my own visual element as the base
which has ultimately lead to me still using a lot of Unitys things, but, created custom visual element I add to them as children to do some things
understandable
i will say though, for all my headaches and complaints about it so far, I am enjoying exploring it
my UI looks 10x better, just its a bit harder to pull together lol
but my codebase is also much cleaner for switching to UIElements in general
if not "smaller" its at least more logically structured
Honestly, it felt easier to deal with than the other system. I was just beginning in Unity at the time, so didn't have much experience with it, but, for some reason I find at least the direction I'm going with UIToolkit to be a lot less convoluted than the other system. I just hated making a gameobject for every little thing
ah UGUI, yeah
I mean, it is almost the same idea with using a Visual Element for every little thing now, but, idk
should I put a scroll view as the child of a foldout, or a foldout as the child of a scroll view
I guess it would make more sense to have it the child of a foldout? So, if the foldout value is false, it won't even show?
yeah cos the foldout's job is to hide and show the thingy
whereas its the thingy's job to manage its own content
so I see this Scroller class, what visual element should I put it as a child of?
for a list
actually, nvm, guess it would depend on what I want to do with it, but, I guess I would put it as a child of the element that holds all the children so it will flex them easy enough
Ideas?
Is there a equivalent to :not in USS? I want to apply a class only if the element is disabled, like .something:not(.unity-disabled)
could be wrong, but, I'm pretty sure you would need to do this through events in c#
I think USS is ONLY for the things under style
Sorry, what do you mean by "under style"? π€
IStyle
the interface
I think the USS is only for setting those values? (Sorry, not 100% sure, as I do all my UIToolkit through C# only)
yes, but you can add "dynamic" styles with USS, like :hover for when the element is being hovered
so you have a set of style properties for when the element is normal and when it is hovered
right, but what I mean is, you can create a USS to handles the dynamic styling for, for example, :hover, but, the USS doesn't handle "events"
well, from what I'm assuming. Let me see if I can find some more info
https://docs.unity3d.com/2022.2/Documentation/Manual/UIE-USS.html might have some info, reading it more in debt now to see if can set any type of trigger or something. Have only quickly scanned over it in the past
I think you can consider hovering an event the same way enabling/disabling an element is an event.
Unity even has, as per the docs, a :disabled option but I needed a :enabled or :not(:disabled) (or the equivalent :not(.unity-disabled))
https://github.com/Unity-Technologies/UnityCsReference/blob/master/ModuleOverrides/com.unity.ui/Core/VisualElement.cs has lead me to believe that these states are checked via c#
how can I make a Transform reference field like this?
so, your suggestion is that I should listen for enabled/disabled events and add/remove the respective class?
yeah, IF it can't be done through USS, which I think it can't.
there doesn't seem to exist an event for enabled/disabled π¦
yeah, you need to either create your own, or mess with valuechange events
why do my foldouts not work correctly-
I restarted the project and they don't scale properly anymore----
it works if I scale the window higher???
okay, I think based off that, you have something flexing wrong
it works in a new file
give me a sec to open up the UI builders see if I can look at it from there
just what I was looking at to ask
that is your problem
you have Shrink at 0
meaning it isn't flex shrinking
Specifies how the item will shrink relative to the rest of the flexible items inside the same container.
yeah I got it
thanks for pointing those variables out
yeah, I'm still confused sometimes and how the flexShrink and Grow work, because sometimes they don't even do the same thing in https://yogalayout.com/playground and not sure why, but I can say this, I have found that almost never do I actually need to mess with flexShrink
and Unity defaults it to 1
yeahhh
grow would be more used-
also, another question, is there any way I can add something like this
let me see if there is a non editor version of object field yet
or does it matter if it is editor?
okay, then you can use UnityEditor.UIElements.ObjectField
and set the objectType to Transform
I can add it through code using that
oh yeah, whoops, sorry. I forget sometimes that I'm not doing this in UIBuilder, let me look at UIBuilder real fast
lmao
okay, so, you need to click on your root element in the Viewport
yeah
in the inspector make sure Editor Extension Authoring is enabled