Using the UI Document component
As mentioned in the Parts of the UI Toolkit System section of this chapter, the UI Document component must be added to a GameObject in your scene so that the UI you’ve created can be rendered. You can do this by either adding the UI Document component to an existing GameObject or selecting + | UI Toolkit | UI Document. This GameObject will have a Transform component and a UI Document component.
Figure 18.13: The Inspector of a UIDocument GameObject
If you do not already have a folder called UI Toolkit
within your projects’s Assets
folder, one will automatically be created for you. Within it, you will find a PanelSettings
asset, and a folder called UnityThemes
. Within UnityThemes
, you will find a TSS file called UnityDefaultRuntimeTheme.tss
. Your UIDocument
GameObject’s UI Document component will automatically have the PanelSettings
asset assigned to the Panel Settings property. However, you will need...