private static string GenerateElementConstructors(CompiledTemplateData compiledTemplateData, out List <ProcessedType> dynamicElementTypes) { StringBuilder builder = new StringBuilder(2048); dynamicElementTypes = new List <ProcessedType>(); foreach (KeyValuePair <Type, ProcessedType> kvp in TypeProcessor.typeMap) { if (kvp.Value.isDynamic) { dynamicElementTypes.Add(kvp.Value); } if (kvp.Key.IsAbstract || kvp.Value.references == 0 || kvp.Value.id < 0) { continue; } builder.Append(s_Indent16); builder.Append("case "); builder.Append(kvp.Value.id); builder.AppendLine(":"); builder.Append(s_Indent20); builder.Append("return new ConstructedElement("); builder.Append(compiledTemplateData.GetTagNameId(kvp.Value.tagName)); builder.Append(", new "); TypeNameGenerator.GetTypeName(kvp.Key, builder); builder.Append("());"); builder.AppendLine(); } return(builder.ToString()); }
private static string GenerateCustomPainterTypes() { string retn = ""; #if UNITY_EDITOR foreach (Type painterType in UnityEditor.TypeCache.GetTypesWithAttribute <CustomPainterAttribute>()) { CustomPainterAttribute attr = painterType.GetCustomAttribute <CustomPainterAttribute>(); retn += $" {{ \"{attr.name}\", typeof({TypeNameGenerator.GetTypeName(painterType)}) }},\n"; } #endif return(retn); }
private static string GenerateDynamicTemplates(CompiledTemplateData compiledTemplateData) { if (compiledTemplateData.dynamicTemplates == null) { return(string.Empty); } StringBuilder builder = new StringBuilder(2048); for (int i = 0; i < compiledTemplateData.dynamicTemplates.size; i++) { DynamicTemplate template = compiledTemplateData.dynamicTemplates.array[i]; builder.Append(s_Indent12); builder.Append("new DynamicTemplate(typeof("); TypeNameGenerator.GetTypeName(template.type, builder); builder.Append("), "); builder.Append(template.typeId); builder.Append(", "); builder.Append(template.templateId); builder.Append("),\n"); } return(builder.ToString()); }