public VisualElement CloneTree(Dictionary <string, VisualElement> slotInsertionPoints) { var tc = new TemplateContainer(name); CloneTree(tc, slotInsertionPoints ?? new Dictionary <string, VisualElement>()); return(tc); }
public VisualElement CloneTree(Dictionary <string, VisualElement> slotInsertionPoints) { TemplateContainer templateContainer = new TemplateContainer(base.name); this.CloneTree(templateContainer, slotInsertionPoints ?? new Dictionary <string, VisualElement>()); return(templateContainer); }
private static VisualElement CreateTemplate(IUxmlAttributes bag, CreationContext ctx) { string alias = ((TemplateAsset)bag).templateAlias; VisualTreeAsset vea = ctx.visualTreeAsset.ResolveUsing(alias); var tc = new TemplateContainer(alias); if (vea == null) { tc.Add(new Label(string.Format("Unknown Element: '{0}'", alias))); } else { vea.CloneTree(tc, ctx.slotInsertionPoints); } if (vea == null) { Debug.LogErrorFormat("Could not resolve template with alias '{0}'", alias); } return(tc); }
private static VisualElement CreateTemplate(IUxmlAttributes bag, CreationContext ctx) { string templateAlias = ((TemplateAsset)bag).templateAlias; VisualTreeAsset visualTreeAsset = ctx.visualTreeAsset.ResolveUsing(templateAlias); TemplateContainer templateContainer = new TemplateContainer(templateAlias); if (visualTreeAsset == null) { templateContainer.Add(new Label(string.Format("Unknown Element: '{0}'", templateAlias))); } else { visualTreeAsset.CloneTree(templateContainer, ctx.slotInsertionPoints); } if (visualTreeAsset == null) { Debug.LogErrorFormat("Could not resolve template with alias '{0}'", new object[] { templateAlias }); } return(templateContainer); }
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc) { base.Init(ve, bag, cc); TemplateContainer templateContainer = ((TemplateContainer)ve); templateContainer.templateId = m_Template.GetValueFromBag(bag); VisualTreeAsset vea = cc.visualTreeAsset.ResolveTemplate(templateContainer.templateId); if (vea == null) { templateContainer.Add(new Label(string.Format("Unknown Element: '{0}'", templateContainer.templateId))); } else { vea.CloneTree(templateContainer, cc.slotInsertionPoints); } if (vea == null) { Debug.LogErrorFormat("Could not resolve template with name '{0}'", templateContainer.templateId); } }