public static CompiledTemplateData LoadPrecompiledTemplates(TemplateSettings templateSettings) { Assembly assembly = AppDomain.CurrentDomain.GetAssemblyByName(templateSettings.assemblyName); Type type = assembly.GetType("UIForia.Generated.UIForiaGeneratedTemplates_" + templateSettings.StrippedApplicationName); if (type == null) { throw new ArgumentException("Trying to use precompiled templates for " + templateSettings.StrippedApplicationName + " but couldn't find the type. Maybe you need to regenerate the code?"); } CompiledTemplateData compiledTemplateData = new CompiledTemplateData(templateSettings); compiledTemplateData.styleImporter.importResolutionPath = Path.Combine(UnityEngine.Application.streamingAssetsPath, "UIForia", compiledTemplateData.templateSettings.StrippedApplicationName); ITemplateLoader loader = (ITemplateLoader)Activator.CreateInstance(type); string[] files = loader.StyleFilePaths; compiledTemplateData.styleImporter.Reset(); // reset because in testing we will already have parsed files, nuke these LightList <UIStyleGroupContainer> styleList = new LightList <UIStyleGroupContainer>(128); Dictionary <string, StyleSheet> styleSheetMap = new Dictionary <string, StyleSheet>(128); MaterialDatabase materialDatabase = loader.GetMaterialDatabase(); for (int i = 0; i < files.Length; i++) { StyleSheet sheet = compiledTemplateData.styleImporter.ImportStyleSheetFromFile(files[i], materialDatabase); styleList.EnsureAdditionalCapacity(sheet.styleGroupContainers.Length); for (int j = 0; j < sheet.styleGroupContainers.Length; j++) { styleList.array[styleList.size++] = sheet.styleGroupContainers[j]; } styleSheetMap.Add(sheet.path, sheet); } compiledTemplateData.templates = loader.LoadTemplates(); compiledTemplateData.slots = loader.LoadSlots(); compiledTemplateData.bindings = loader.LoadBindings(); compiledTemplateData.templateMetaData = loader.LoadTemplateMetaData(styleSheetMap, styleList.array); for (int i = 0; i < compiledTemplateData.templateMetaData.Length; i++) { compiledTemplateData.templateMetaData[i].compiledTemplateData = compiledTemplateData; } compiledTemplateData.constructElement = loader.ConstructElement; compiledTemplateData.dynamicTemplates = loader.DynamicTemplates; return(compiledTemplateData); }