// writes a file to the project folder private static void WriteCodeFile() { Com.WriteCodeFile(FilePath, builder => { WrappedInt indentCount = 0; builder.AppendIndentLine(indentCount, Com.AutoGenTemplate); builder.AppendIndentLine(indentCount, "using UnityEngine;"); builder.Append(Environment.NewLine); builder.AppendIndentLine(indentCount, Com.NameSpaceTemplate); using (new CurlyIndent(builder, indentCount)) { builder.AppendIndentFormatLine(indentCount, "public static class {0}", FileName); using (new CurlyIndent(builder, indentCount)) { // string foreach (string name in Com.names) { builder.AppendIndentFormatLine(indentCount, "public const string {0}{1} = @\"{2}\";", CodeGeneratorCommon.StringPrefix, Com.MakeIdentifier(name), Com.EscapeDoubleQuote(name)); } builder.Append(Environment.NewLine); // hash storage foreach (string name in Com.names) { builder.AppendIndentFormatLine(indentCount, "public const int {0} = {1};", Com.MakeIdentifier(name), Animator.StringToHash(name)); } } } }); }
public CurlyIndent(StringBuilder b, WrappedInt counter) { val = counter; builder = b; builder.AppendIndentLine(val, "{"); ++val; }
// writes a file to the project folder private static void WriteCodeFile() { Com.WriteCodeFile(FilePath, builder => { WrappedInt indentCount = 0; builder.AppendIndentLine(indentCount, Com.AutoGenTemplate); builder.AppendIndentLine(indentCount, Com.NameSpaceTemplate); using (new CurlyIndent(builder, indentCount)) { builder.AppendIndentFormatLine(indentCount, "public static class {0}", FileName); using (new CurlyIndent(builder, indentCount)) { foreach (string name in Com.names) { builder.AppendIndentFormatLine(indentCount, "public const string {0} = @\"{1}\";", Com.MakeIdentifier(name), Com.EscapeDoubleQuote(name)); } } } }); }
// writes a file to the project folder private static void WriteCodeFile() { Com.WriteCodeFile(FilePath, builder => { WrappedInt indentCount = 0; builder.AppendIndentLine(indentCount, Com.AutoGenTemplate); builder.AppendIndentLine(indentCount, Com.NameSpaceTemplate); using (new CurlyIndent(builder, indentCount)) { builder.AppendIndentFormatLine(indentCount, "public static class {0}", FileName); using (new CurlyIndent(builder, indentCount)) { foreach (string name in Com.names) { // ex) assets/scenes/menu.unity -> menu var tail = name.Substring(name.LastIndexOf('/') + 1); var result = tail.Substring(0, tail.LastIndexOf('.')); builder.AppendIndentFormatLine(indentCount, "public const string {0} = @\"{1}\";", Com.MakeIdentifier(name), Com.EscapeDoubleQuote(name)); } } } }); }