Greetings,
I am building a custom UI Control in UI Toolkit. I designed it in UI Builder using visual elements, labels, etc. and set their colors and other attributes. The control looks great in UI builder. Then I created a class and added the following code:
public class PanelApplicationSection : VisualElement
{
#region Boilerplate for showing up in the UI Builder.
//[UnityEngine.Scripting.Preserve]
internal new class UxmlFactory : UxmlFactory { }
internal new class UxmlTraits : VisualElement.UxmlTraits { }
public PanelApplicationSection()
{
//VisualTreeAsset asset = AssetDatabase.LoadAssetAtPath(
// "Assets/Resources/UserInterface/ScreenHome.uxml");
//VisualTreeAsset asset = (VisualTreeAsset)Resources.Load("UserInterface/ScreenHome.uxml");
//asset.CloneTree(this);
}
#endregion
// Fields
private VisualElement panelContainer => this.Q("panel_container");
private Label sectionTitle => this.Q("section_title");
private Label sectionTypeTitle => this.Q("section_type_title");
private VisualElement icon => this.Q("icon");
private VisualElement bottonBanner => this.Q("bottom_banner");
private Button buttonPlay => this.Q("button_play");
// Properties
public VisualElement PanelContainer
{
get { return panelContainer; }
}
}
It doesn’t work. The custom control when added to another Uxml document in UI Builder just looks like a blank white area. None of the elements (e.g., labels, visual elements, images, etc.) show up.
I have looked at several YouTube videos and they seem to add elements in code first. I want to design it in UI Builder, then add the coding.
Any idea how I can make them shown up or how I can make my custom UI controller work?
Thanks