void VisitIn(DOMImport import) { Assert.IsFalse(string.IsNullOrEmpty(import.textContent), "content is required for <import />"); var referencedFile = Path.Combine(m_WorkingDirectory, import.textContent).Replace("\\", "/"); m_FileDependencies.Add(referencedFile); if (!File.Exists(referencedFile)) { Debug.LogWarningFormat("Referenced file {0} is missing", referencedFile); return; } DOMDocument definitionInstance = null; using (var reader = new StreamReader(referencedFile)) { definitionInstance = ViewGenerator.serializer.Deserialize(reader) as DOMDocument; } if (definitionInstance != null && definitionInstance.nodes != null) { foreach (var node in definitionInstance.nodes) { Visit(node); } } }
public string GenerateFrom(string workingDirectory, string assetName, DOMDocument document) { m_Properties.Clear(); m_Usings.Clear(); m_Commands.Clear(); m_FileDependencies.Clear(); m_WorkingDirectory = workingDirectory; m_File = new CSFile(document.@namespace) .AddWarningDisable(414) .AddInclude("UnityEditor.Experimental.VisualElements"); m_Class = new CSClass(Scope.Internal, assetName, CSClass.Modifier.Partial) .AddParent("IMGUIVisualContainer"); m_File.AddClass(m_Class); if (document.nodes != null) { for (int i = 0; i < document.nodes.Length; i++) { Visit(document.nodes[i]); } } VisitIn(document.stylesheet); VisitIn(document.root); Build(); var builder = new StringBuilder(); m_File.GenerateIn(builder); return(builder.ToString()); }