private void LoadTemplate(VisualTreeAsset tpl) { tpl.CloneTree(this, new Dictionary <string, VisualElement>()); InitBadgeComponent("tip", tipUssClassName, ref m_TipElement); InitBadgeComponent("icon", iconUssClassName, ref m_IconElement); InitBadgeComponent("text", textUssClassName, ref m_TextElement); if (m_TipElement != null) { ////we make sure the tip is in the back m_TipElement.SendToBack(); } name = "IconBadge"; AddToClassList(ussClassName); AddStyleSheetPath(defaultStylePath); if (m_TextElement != null) { m_TextElement.RemoveFromHierarchy(); //we need to add the style sheet to the Text element as well since it will be parented elsewhere m_TextElement.AddStyleSheetPath(defaultStylePath); m_TextElement.style.whiteSpace = WhiteSpace.Normal; m_TextElement.RegisterCallback <GeometryChangedEvent>((evt) => ComputeTextSize()); m_TextElement.pickingMode = PickingMode.Ignore; } }