Elements have per-element attributes which can be set in UXML. You can think of them as constructor or initialization arguments. This includes the name
attribute. The base VisualElement
class comes with a few standard attributes that all elements share (since all elements inherit from VisualElement
), like: name
, tooltip
, and tabindex
. More advanced elements and controls will have additional attributes you can set, for example, the Label
adds the text
attribute.
A small note on the text
attribute. The text
attribute supports multi-line text. Just use Enter to add newline characters in the Inspector.
All attributes, both standard and custom, appear at the top of the Inspector in a section that has the same name as the name of the element’s type. For example, if you click on a Button
, look for a section in the Inspector called Button.
You can set the value of an attribute by changing the corresponding field in the attribute section. If the field appears bold with a solid line on the left of the field’s label, it means the attribute is already set and not using the default. For example, setting tooltip
from empty to test
and then back to empty is different from never setting it in the first place: the first case is unset
while the second case is set to empty
. What this attribute is set
means is there’s an entry in the UXML text on this element setting this attribute to a
value
If the attribute isn’t mentioned in the UXML text, it’s not set
.
You can unset an attribute by right-clicking on the field’s label and choosing Unset. You can unset all attributes, including the name
attribute, by right-clicking on any attribute field and choosing Unset All.
The only attribute you can change directly in the Canvas is the text
attribute on text elements. To change the text
attribute on something like a Button
or a Label
you can double-click on it in the Canvas. A temporary text field will appear, using the same font settings as the original text:
Pressing Enter commits the change. If the text
attribute contains newline characters, use Shift + Enter to commit the change. Press Esc to cancel any changes.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.