Ejemplo n.º 1
0
        public override void OnImportAsset(AssetImportContext args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            VisualTreeAsset vta;

            var importer = new UXMLImporterImpl(args);

            importer.Import(out vta);
            args.AddObjectToAsset("tree", vta);
            args.SetMainObject(vta);

            if (!vta.inlineSheet)
            {
                vta.inlineSheet = ScriptableObject.CreateInstance <StyleSheet>();
            }

            // Make sure imported objects aren't editable in the Inspector
            vta.hideFlags             = HideFlags.NotEditable;
            vta.inlineSheet.hideFlags = HideFlags.NotEditable;

            args.AddObjectToAsset("inlineStyle", vta.inlineSheet);
        }
Ejemplo n.º 2
0
        // Parses the XML file to figure out dependencies to other UXML/USS files
        static string[] GatherDependenciesFromSourceFile(string assetPath)
        {
            XDocument doc;

            try
            {
                doc = XDocument.Parse(File.ReadAllText(assetPath), LoadOptions.SetLineInfo);
            }
            catch (Exception)
            {
                // We want to be silent here, all XML syntax errors will be reported during the actual import
                return(new string[] {});
            }
            var dependencies = new List <string>();

            UXMLImporterImpl.PopulateDependencies(assetPath, doc.Root, dependencies);

            return(dependencies.ToArray());
        }