internal static string GetSelectorString(VisualElement element) { var complexSelector = element.GetProperty(BuilderConstants.ElementLinkedStyleSelectorVEPropertyName) as StyleComplexSelector; var selectorStr = StyleSheetToUss.ToUssSelector(complexSelector); return(selectorStr); }
protected override bool StartDrag(VisualElement target, Vector2 mousePosition, VisualElement pill) { m_ElementsToReparent.Clear(); // Create list of elements to reparent. foreach (var selectedElement in selection.selection) { var elementToReparent = new ElementToReparent() { element = selectedElement, oldParent = selectedElement.parent, oldIndex = selectedElement.parent.IndexOf(selectedElement) }; m_ElementsToReparent.Add(elementToReparent); } // We still need a primary element that is "being dragged" for visualization purporses. m_TargetElementToReparent = target.GetProperty(BuilderConstants.ExplorerItemElementLinkVEPropertyName) as VisualElement; if (!m_TargetElementToReparent.IsSelector() && !m_TargetElementToReparent.IsStyleSheet()) { return(false); } // We use the primary target element for our pill info. var pillLabel = pill.Q <Label>(); pillLabel.text = m_TargetElementToReparent.IsSelector() ? StyleSheetToUss.ToUssSelector(m_TargetElementToReparent.GetStyleComplexSelector()) : m_TargetElementToReparent.GetStyleSheet().name + BuilderConstants.UssExtension; pillLabel.RemoveFromClassList(BuilderConstants.ElementClassNameClassName); return(true); }
public static StyleComplexSelector Swallow(this StyleSheet toStyleSheet, StyleSheet fromStyleSheet, StyleComplexSelector fromSelector) { var toSelector = toStyleSheet.AddSelector(StyleSheetToUss.ToUssSelector(fromSelector)); SwallowStyleRule(toStyleSheet, toSelector, fromStyleSheet, fromSelector); return(toSelector); }
internal static void AddSelectorElementsFromStyleSheet(VisualElement documentElement, List <BuilderDocumentOpenUSS> openUssFiles) { var selectorContainerElement = GetSelectorContainerElement(documentElement); selectorContainerElement.Clear(); for (int i = 0; i < openUssFiles.Count; ++i) { var styleSheet = openUssFiles[i].Sheet; var styleSheetElement = new VisualElement(); styleSheetElement.name = styleSheet.name; styleSheetElement.SetProperty(BuilderConstants.ElementLinkedStyleSheetVEPropertyName, styleSheet); styleSheetElement.SetProperty(BuilderConstants.ElementLinkedStyleSheetIndexVEPropertyName, i); styleSheetElement.styleSheets.Add(styleSheet); selectorContainerElement.Add(styleSheetElement); foreach (var complexSelector in styleSheet.complexSelectors) { var complexSelectorStr = StyleSheetToUss.ToUssSelector(complexSelector); if (complexSelectorStr == BuilderConstants.SelectedStyleSheetSelectorName || complexSelectorStr.StartsWith(BuilderConstants.UssSelectorNameSymbol + BuilderConstants.StyleSelectorElementName)) { continue; } var ssVE = CreateNewSelectorElement(styleSheet, complexSelector); styleSheetElement.Add(ssVE); } } }
internal static string GenerateUSS(this StyleSheet styleSheet) { string result = null; try { result = StyleSheetToUss.ToUssString(styleSheet); } catch (Exception ex) { if (!styleSheet.name.Contains(BuilderConstants.InvalidUXMLOrUSSAssetNameSuffix)) { var message = string.Format(BuilderConstants.InvalidUSSDialogMessage, styleSheet.name); BuilderDialogsUtility.DisplayDialog(BuilderConstants.InvalidUSSDialogTitle, message); styleSheet.name = styleSheet.name + BuilderConstants.InvalidUXMLOrUSSAssetNameSuffix; } else { var name = styleSheet.name.Replace(BuilderConstants.InvalidUXMLOrUSSAssetNameSuffix, string.Empty); var message = string.Format(BuilderConstants.InvalidUSSDialogMessage, name); Builder.ShowWarning(message); } Debug.LogError(ex.Message + "\n" + ex.StackTrace); } return(result); }
public static void Swallow(this StyleSheet toStyleSheet, StyleSheet fromStyleSheet) { foreach (var fromSelector in fromStyleSheet.complexSelectors) { var toSelector = toStyleSheet.AddSelector(StyleSheetToUss.ToUssSelector(fromSelector)); SwallowStyleRule(toStyleSheet, toSelector, fromStyleSheet, fromSelector); } }
VisualElement GeneratedMatchingSelectors() { m_MatchingSelectors.GetElementMatchers(); if (m_MatchingSelectors.matchedRulesExtractor.selectedElementRules == null || m_MatchingSelectors.matchedRulesExtractor.selectedElementRules.Count <= 0) { return(null); } var container = new VisualElement(); int ruleIndex = 0; var options = new UssExportOptions(); var sb = new StringBuilder(); foreach (var rule in m_MatchingSelectors.matchedRulesExtractor.selectedElementRules) { var selectorStr = StyleSheetToUss.ToUssSelector(rule.matchRecord.complexSelector); StyleProperty[] props = rule.matchRecord.complexSelector.rule.properties; var ruleFoldout = new PersistedFoldout() { value = false, text = selectorStr, viewDataKey = "builder-inspector-rule-foldout__" + ruleIndex }; ruleIndex++; container.Add(ruleFoldout); if (props.Length == 0) { var label = new Label("None"); label.AddToClassList(BuilderConstants.InspectorEmptyFoldoutLabelClassName); ruleFoldout.Add(label); continue; } for (int j = 0; j < props.Length; j++) { sb.Clear(); StyleSheetToUss.ToUssString(rule.matchRecord.sheet, options, props[j], sb); string s = sb.ToString(); s = s?.ToLower(); var textField = new TextField(props[j].name) { value = s }; textField.isReadOnly = true; ruleFoldout.Add(textField); } } return(container); }
internal static List <string> GetSelectorStrings(this StyleSheet styleSheet) { var list = new List <string>(); foreach (var complexSelector in styleSheet.complexSelectors) { var str = StyleSheetToUss.ToUssSelector(complexSelector); list.Add(str); } return(list); }
public static bool FindVariableOrigin(VisualElement currentVisualElement, string variableName, out StyleSheet outStyleSheet, out StyleComplexSelector outSelector) { outSelector = null; outStyleSheet = null; if (string.IsNullOrEmpty(variableName)) { return(false); } // Traverse the element's parent hierarchy to find best matching selector that define the variable var extractor = new MatchedRulesExtractor(); var current = currentVisualElement; while (current != null) { extractor.selectedElementRules.Clear(); extractor.selectedElementStylesheets.Clear(); extractor.FindMatchingRules(current); var matchedRules = extractor.selectedElementRules; for (var i = matchedRules.Count - 1; i >= 0; --i) { var matchRecord = matchedRules.ElementAt(i).matchRecord; var ruleProperty = matchRecord.sheet.FindProperty(matchRecord.complexSelector.rule, variableName); if (ruleProperty != null) { outSelector = matchRecord.complexSelector; outStyleSheet = matchRecord.sheet; break; } } if (outSelector != null) { break; } current = current.parent; } // If the current visual element is a fake elemennt created for the selector being edited and that the selector found is a fake selector then return the effective selector associated to the fake visual element if (outSelector != null && current == currentVisualElement && StyleSheetToUss.ToUssSelector(outSelector).Contains(BuilderConstants.StyleSelectorElementName)) { outSelector = currentVisualElement.GetStyleComplexSelector(); } return(outSelector != null); }
public void Show(VariableEditingHandler handler, string variableName, StyleSheet varStyleSheetOrigin, StyleComplexSelector varSelectorOrigin) { m_CurrentHandler = handler; m_VarNameLabel.text = !string.IsNullOrEmpty(variableName) ? variableName : "None"; if (!string.IsNullOrEmpty(variableName) && varSelectorOrigin != null) { var fullPath = AssetDatabase.GetAssetPath(varStyleSheetOrigin); string displayPath = null; if (string.IsNullOrEmpty(fullPath)) { displayPath = varStyleSheetOrigin.name; } else { if (fullPath == "Library/unity editor resources") { displayPath = varStyleSheetOrigin.name; } else { displayPath = Path.GetFileName(fullPath); } } m_SelectorSourceLabel.text = $"{StyleSheetToUss.ToUssSelector(varSelectorOrigin)} ({displayPath})"; } else { m_SelectorSourceLabel.text = "None"; } var pos = handler.labelElement.ChangeCoordinatesTo(parent, Vector2.zero); pos.x = parent.layout.width - (style.minWidth.value.value + handler.inspector.resolvedStyle.width + BuilderConstants.TooltipPreviewYOffset); style.left = pos.x; style.top = pos.y; m_Showing = true; Show(); // TODO: Will need to bring this back once we can also do the dragger at the same time. //Focus(); }
internal static StyleComplexSelector FindSelector(this StyleSheet styleSheet, string selectorStr) { // Remove extra whitespace. var selectorSplit = selectorStr.Split(' '); selectorStr = String.Join(" ", selectorSplit); foreach (var complexSelector in styleSheet.complexSelectors) { var str = StyleSheetToUss.ToUssSelector(complexSelector); if (str == selectorStr) { return(complexSelector); } } return(null); }
public void CopyElement(VisualElement element) { var vea = element.GetVisualElementAsset(); if (vea != null) { BuilderEditorUtility.SystemCopyBuffer = VisualTreeAssetToUXML.GenerateUXML(m_PaneWindow.document.visualTreeAsset, null, vea); return; } var selector = element.GetStyleComplexSelector(); if (selector != null) { BuilderEditorUtility.SystemCopyBuffer = StyleSheetToUss.ToUssString(m_PaneWindow.document.mainStyleSheet, selector); return; } }
internal static void AddSelectorElementsFromStyleSheet( VisualElement documentElement, List <BuilderDocumentOpenUSS> USSFiles, int startInd = 0, bool belongsToParent = false, string associatedUXMLFileName = null) { for (int i = 0; i < USSFiles.Count; ++i) { var selectorContainerElement = GetSelectorContainerElement(documentElement); var styleSheet = USSFiles[i].styleSheet; var styleSheetElement = new VisualElement(); styleSheetElement.name = styleSheet.name; styleSheetElement.SetProperty(BuilderConstants.ElementLinkedStyleSheetVEPropertyName, styleSheet); if (belongsToParent) { styleSheetElement.SetProperty(BuilderConstants.ExplorerItemLinkedUXMLFileName, associatedUXMLFileName); } styleSheetElement.SetProperty(BuilderConstants.ElementLinkedStyleSheetIndexVEPropertyName, i + startInd); styleSheetElement.styleSheets.Add(styleSheet); selectorContainerElement?.Add(styleSheetElement); foreach (var complexSelector in styleSheet.complexSelectors) { var complexSelectorStr = StyleSheetToUss.ToUssSelector(complexSelector); if (complexSelectorStr == BuilderConstants.SelectedStyleSheetSelectorName || complexSelectorStr.StartsWith(BuilderConstants.UssSelectorNameSymbol + BuilderConstants.StyleSelectorElementName)) { continue; } var ssVE = CreateNewSelectorElement(styleSheet, complexSelector); if (belongsToParent) { ssVE.AddToClassList(BuilderConstants.StyleSelectorBelongsParent); } styleSheetElement.Add(ssVE); } } }
public static List <string> GetMatchingSelectorsOnElement(VisualElement documentElement) { var matchedElementsSelector = new MatchedRulesExtractor(); matchedElementsSelector.FindMatchingRules(documentElement); if (matchedElementsSelector.selectedElementRules == null || matchedElementsSelector.selectedElementRules.Count <= 0) { return(null); } var complexSelectors = new List <string>(); foreach (var rule in matchedElementsSelector.selectedElementRules) { var complexSelector = rule.matchRecord.complexSelector; var complexSelectorString = StyleSheetToUss.ToUssSelector(complexSelector); complexSelectors.Add(complexSelectorString); } return(complexSelectors); }
public static VisualElement FindSelectorElement(VisualElement documentRootElement, string selectorStr) { var selectorContainer = GetSelectorContainerElement(documentRootElement); var allSelectorElements = selectorContainer.Query().Where((e) => true).ToList(); foreach (var selectorElement in allSelectorElements) { var complexSelector = selectorElement.GetProperty(BuilderConstants.ElementLinkedStyleSelectorVEPropertyName) as StyleComplexSelector; if (complexSelector == null) { continue; } var currentSelectorStr = StyleSheetToUss.ToUssSelector(complexSelector); if (currentSelectorStr == selectorStr) { return(selectorElement); } } return(null); }
void HighlightAllElementsMatchingSelectorElement(VisualElement selectorElement) { var selector = selectorElement.GetProperty(BuilderConstants.ElementLinkedStyleSelectorVEPropertyName) as StyleComplexSelector; if (selector == null) { return; } var selectorStr = StyleSheetToUss.ToUssSelector(selector); var matchingElements = BuilderSharedStyles.GetMatchingElementsForSelector(m_DocumentRootElement, selectorStr); if (matchingElements == null) { return; } foreach (var element in matchingElements) { HighlightItemInTargetWindow(element); } }
internal static void AddSelectorElementsFromStyleSheet(VisualElement documentElement, StyleSheet styleSheet) { var selectorContainerElement = GetSelectorContainerElement(documentElement); selectorContainerElement.SetProperty(BuilderConstants.ElementLinkedStyleSheetVEPropertyName, styleSheet); selectorContainerElement.Clear(); if (styleSheet == null) { return; } foreach (var complexSelector in styleSheet.complexSelectors) { var complexSelectorStr = StyleSheetToUss.ToUssSelector(complexSelector); if (complexSelectorStr == BuilderConstants.SelectedStyleSheetSelectorName) { continue; } var ssVE = CreateNewSelectorElement(complexSelector); selectorContainerElement.Add(ssVE); } }
void CloneTree() { m_Container.Clear(); m_StyleSheetContents.Clear(); m_VisualTreeAssetContents.Clear(); m_Container.styleSheets.Clear(); if (m_VisualTreeAsset != null) { m_VisualTreeAsset.LinkedCloneTree(m_Container); var canvas = m_Container.Q("sample-canvas"); var canvasAsset = canvas.GetVisualElementAsset(); var newButton = m_VisualTreeAsset.AddElement(canvasAsset, "UnityEngine.UIElements.Button"); newButton.AddProperty("name", "new-guy"); newButton.AddProperty("text", "Canvas Button 2!"); newButton.AddStyleClass("new-guy-type"); newButton.AddStyleClass("some-button"); newButton.RemoveStyleClass("some-button"); newButton.AddStyleClass("some-fancy-button"); { // Add max-width to newButton. var rule = m_VisualTreeAsset.GetOrCreateInlineStyleRule(newButton); var prop = m_VisualTreeAsset.inlineSheet.AddProperty(rule, "max-width"); var val = m_VisualTreeAsset.inlineSheet.AddValue(prop, 200); } { // Add max-width to canvas. var rule = m_VisualTreeAsset.GetOrCreateInlineStyleRule(canvasAsset); var prop = m_VisualTreeAsset.inlineSheet.AddProperty(rule, "max-width"); var val = m_VisualTreeAsset.inlineSheet.AddValue(prop, 500); } { // Change border of canvas. var rule = m_VisualTreeAsset.GetOrCreateInlineStyleRule(canvasAsset); var prop = m_VisualTreeAsset.inlineSheet.FindLastProperty(rule, "border-width"); m_VisualTreeAsset.inlineSheet.SetValue(prop.values[0], 10); } { // Remove max-width var rule = m_VisualTreeAsset.GetOrCreateInlineStyleRule(canvasAsset); var prop = m_VisualTreeAsset.inlineSheet.FindLastProperty(rule, "max-width"); m_VisualTreeAsset.inlineSheet.RemoveProperty(rule, prop); } var newButton2 = m_VisualTreeAsset.AddElement(canvasAsset, "UnityEngine.UIElements.Button"); m_VisualTreeAsset.RemoveElement(newButton2); var newInstance = m_VisualTreeAsset.AddTemplateInstance(canvasAsset, "SampleSection"); newInstance.SetAttributeOverride("section-text-field", "label", "label programmatically written!"); newInstance.SetAttributeOverride("section-text-field", "text", "text programmatically written!"); newInstance.RemoveAttributeOverride("section-text-field", "text"); newInstance.AddStyleSheetPath(s_CanvasInstanceUSSPath); var overriddenSection = m_VisualTreeAsset.FindElementByName("overridden-section"); if (overriddenSection != null) { overriddenSection.RemoveStyleSheetPath(s_CanvasInstanceUSSPath); } // Add UXML string. var uxmlString = m_VisualTreeAsset.GenerateUXML(null); m_VisualTreeAssetContents.Add(new Label(uxmlString)); // Add inline stylesheet. var inlineBuilder = new StringBuilder(); foreach (var rule in m_VisualTreeAsset.inlineSheet.rules) { inlineBuilder.Append("{\n"); var exportOptions = new UssExportOptions(); StyleSheetToUss.ToUssString(m_VisualTreeAsset.inlineSheet, exportOptions, rule, inlineBuilder); inlineBuilder.Append("}\n"); } var inlineStyleSheetString = inlineBuilder.ToString(); m_VisualTreeAssetContents.Add(new Label(inlineStyleSheetString)); m_Container.Clear(); m_VisualTreeAsset.LinkedCloneTree(m_Container); } if (m_StyleSheet != null) { // Add width //var firstSelector = m_StyleSheet.complexSelectors.First(); //var firstSelector = m_StyleSheet.FindSelector(".blue#red > .green .pink"); var firstSelector = m_StyleSheet.FindSelector(".unity-button"); if (firstSelector != null) { var widthProperty = m_StyleSheet.AddProperty(firstSelector, "width"); var widthValue = m_StyleSheet.AddValue(widthProperty, 62); m_StyleSheet.SetValue(widthValue, 82); m_StyleSheet.RemoveProperty(firstSelector, widthProperty); var borderWidthProperty = m_StyleSheet.AddProperty(firstSelector, "border-width"); m_StyleSheet.AddValue(borderWidthProperty, 1); m_StyleSheet.AddValue(borderWidthProperty, 2); m_StyleSheet.AddValue(borderWidthProperty, 5); var leftBorderWidthValue = m_StyleSheet.AddValue(borderWidthProperty, 8); m_StyleSheet.RemoveValue(borderWidthProperty, leftBorderWidthValue); var borderColorProperty = m_StyleSheet.AddProperty(firstSelector, "border-color"); var borderColorValue = m_StyleSheet.AddValue(borderColorProperty, Color.red); m_StyleSheet.SetValue(borderColorValue, Color.green); } var newSelector = m_StyleSheet.AddSelector(".unity-button Label"); { var widthProperty = m_StyleSheet.AddProperty(newSelector, "width"); var widthValue = m_StyleSheet.AddValue(widthProperty, 62); m_StyleSheet.SetValue(widthValue, 82); } // // Add USS contents. //var selectorStrings = m_StyleSheet.GetSelectorStrings(); //foreach (var selectorString in selectorStrings) //m_StyleSheetContents.Add(new Label(selectorString)); // Add USS string. var ussString = m_StyleSheet.GenerateUSS(); m_StyleSheetContents.Add(new Label(ussString)); //m_Container.styleSheets.Add(m_StyleSheet); } }
internal static string GenerateUSS(this StyleSheet styleSheet) { return(StyleSheetToUss.ToUssString(styleSheet)); }
protected override string ExplorerGetDraggedPillText(VisualElement targetElement) { return(targetElement.IsSelector() ? StyleSheetToUss.ToUssSelector(targetElement.GetStyleComplexSelector()) : targetElement.GetStyleSheet().name + BuilderConstants.UssExtension); }
public bool CopySelection() { ClearCopyBuffer(); if (m_Selection.isEmpty) { return(false); } // UXML var veas = new List <VisualElementAsset>(); foreach (var element in m_Selection.selection) { var vea = element.GetVisualElementAsset(); if (vea == null) { veas.Clear(); break; // Mixed type selections are not supported. } // Check if current element is a child of another selected element. if (element.HasAnyAncestorInList(m_Selection.selection)) { continue; } veas.Add(vea); } if (veas.Count > 0) { BuilderEditorUtility.systemCopyBuffer = VisualTreeAssetToUXML.GenerateUXML(m_PaneWindow.document.visualTreeAsset, null, veas); return(true); } // USS var ussSnippetBuilder = new StringBuilder(); foreach (var element in m_Selection.selection) { var selector = element.GetStyleComplexSelector(); if (selector == null) { ussSnippetBuilder.Length = 0; break; // Mixed type selections are not supported. } // Check if current element is a child of another selected element. if (element.HasAnyAncestorInList(m_Selection.selection)) { continue; } var styleSheet = element.GetClosestStyleSheet(); StyleSheetToUss.ToUssString(styleSheet, selector, ussSnippetBuilder); } if (ussSnippetBuilder.Length > 0) { BuilderEditorUtility.systemCopyBuffer = ussSnippetBuilder.ToString(); return(true); } return(false); }
static void GenerateUXMLRecursive( VisualTreeAsset vta, string vtaPath, VisualElementAsset root, Dictionary <int, List <VisualElementAsset> > idToChildren, StringBuilder stringBuilder, int depth, bool writingToFile) { Indent(stringBuilder, depth); stringBuilder.Append("<"); AppendElementTypeName(root, stringBuilder); // Add all non-style attributes. AppendElementNonStyleAttributes(root, stringBuilder, writingToFile); // Add style classes to class attribute. if (root.classes != null && root.classes.Length > 0) { stringBuilder.Append(" class=\""); for (int i = 0; i < root.classes.Length; i++) { if (i > 0) { stringBuilder.Append(" "); } stringBuilder.Append(root.classes[i]); } stringBuilder.Append("\""); } // Add inline StyleSheet attribute. if (root.ruleIndex != -1) { if (vta.inlineSheet == null) { Debug.LogWarning("VisualElementAsset has a RuleIndex but no inlineStyleSheet"); } else { StyleRule r = vta.inlineSheet.rules[root.ruleIndex]; if (r.properties != null && r.properties.Length > 0) { var ruleBuilder = new StringBuilder(); var exportOptions = new UssExportOptions(); exportOptions.propertyIndent = string.Empty; StyleSheetToUss.ToUssString(vta.inlineSheet, exportOptions, r, ruleBuilder); var ruleStr = ruleBuilder.ToString(); // Need to remove newlines here before we give it to // AppendElementAttribute() so we don't add " " everywhere. ruleStr = ruleStr.Replace("\n", " "); ruleStr = ruleStr.Replace("\r", ""); ruleStr = ruleStr.Trim(); AppendElementAttribute("style", ruleStr, stringBuilder); } } } // If we have no children, avoid adding the full end tag and just end the open tag. bool hasChildTags = false; // Add special children. // TODO: What's the difference between these two ifdef options? #if false var styleSheets = root.stylesheets; if (styleSheets != null && styleSheets.Count > 0) { bool newLineAdded = false; foreach (var styleSheet in styleSheets) { var path = AssetDatabase.GetAssetPath(styleSheet); ProcessStyleSheetPath( vtaPath, path, stringBuilder, depth, ref newLineAdded, ref hasChildTags); } } #else var styleSheetPaths = root.GetStyleSheetPaths(); if (styleSheetPaths != null && styleSheetPaths.Count > 0) { bool newLineAdded = false; foreach (var path in styleSheetPaths) { ProcessStyleSheetPath( vtaPath, path, stringBuilder, depth, ref newLineAdded, ref hasChildTags); } } #endif var templateAsset = root as TemplateAsset; if (templateAsset != null && templateAsset.attributeOverrides != null && templateAsset.attributeOverrides.Count > 0) { if (!hasChildTags) { stringBuilder.Append(">"); stringBuilder.Append(BuilderConstants.NewlineCharFromEditorSettings); } var overridesMap = new Dictionary <string, List <TemplateAsset.AttributeOverride> >(); foreach (var attributeOverride in templateAsset.attributeOverrides) { if (!overridesMap.ContainsKey(attributeOverride.m_ElementName)) { overridesMap.Add(attributeOverride.m_ElementName, new List <TemplateAsset.AttributeOverride>()); } overridesMap[attributeOverride.m_ElementName].Add(attributeOverride); } foreach (var attributeOverridePair in overridesMap) { var elementName = attributeOverridePair.Key; var overrides = attributeOverridePair.Value; Indent(stringBuilder, depth + 1); stringBuilder.Append("<AttributeOverrides"); AppendElementAttribute("element-name", elementName, stringBuilder); foreach (var attributeOverride in overrides) { AppendElementAttribute(attributeOverride.m_AttributeName, attributeOverride.m_Value, stringBuilder); } stringBuilder.Append(" />"); stringBuilder.Append(BuilderConstants.NewlineCharFromEditorSettings); } hasChildTags = true; } // Iterate through child elements. List <VisualElementAsset> children; if (idToChildren != null && idToChildren.TryGetValue(root.id, out children) && children.Count > 0) { if (!hasChildTags) { stringBuilder.Append(">"); stringBuilder.Append(BuilderConstants.NewlineCharFromEditorSettings); } children.Sort(VisualTreeAssetUtilities.CompareForOrder); foreach (VisualElementAsset childVea in children) { GenerateUXMLRecursive( vta, vtaPath, childVea, idToChildren, stringBuilder, depth + 1, writingToFile); } hasChildTags = true; } if (hasChildTags) { Indent(stringBuilder, depth); stringBuilder.Append("</"); AppendElementTypeName(root, stringBuilder); stringBuilder.Append(">"); stringBuilder.Append(BuilderConstants.NewlineCharFromEditorSettings); } else { stringBuilder.Append(" />"); stringBuilder.Append(BuilderConstants.NewlineCharFromEditorSettings); } }