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 InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary.
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.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.