public override VisualElement LoadTemplate(string path, Dictionary <string, VisualElement> slots = null) { VisualTreeAsset visualTreeAsset = Panel.loadResourceFunc(path, typeof(VisualTreeAsset)) as VisualTreeAsset; VisualElement result; if (visualTreeAsset == null) { result = null; } else { result = visualTreeAsset.CloneTree(slots); } return(result); }
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); }
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); }
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); } }