private static void GenerateCode() { generator.GenerateCodeFile(FilePath, generator.GetOutputPath(), content => { WrappedInt indentCount = 0; // NOTE: indentCount is automatically increamented or decreamented by // ContentWriter methods // An indent is added when a new CurlyBrackets IDisposable instance is created // and removed everytime that IDisposable instance is disposed of // (when the control has excited from the using statement) content.WriteIndentedLine(indentCount, generator.GetHeaderText(instance.GetScriptName())); content.WriteImports("UnityEngine"); using (new CurlyBrackets(content, ConstantGenerator.OutputFileNamespace, indentCount)) { using (new CurlyBrackets(content, "public static class " + FileName, indentCount)) { foreach (string property in instance.newTags) { content.WriteIndentedFormatLine(indentCount, "public const string {0} = @\"{1}\";", generator.MakeIdentifier(property), generator.EscapeDoubleQuote(property)); } } } }); }
/// <summary> /// inserts/writes an indented curly brackets /// </summary> /// <param name="content_">stringbuilder content</param> /// <param name="indentCount_">number of indents</param> public CurlyBrackets(StringBuilder content_, WrappedInt indentCount_) { indentCount = indentCount_; content = content_; content.WriteIndentedLine(indentCount, "{"); ++indentCount; }
private static void GenerateCode() { generator.GenerateCodeFile(FilePath, generator.GetOutputPath(), content => { WrappedInt indentCount = 0; // NOTE: indentCount is automatically increamented or decreamented by // ContentWriter methods // An indent is added when a new CurlyBrackets IDisposable instance is created // and removed everytime that IDisposable instance is disposed of // (when the control has excited from the using statement) content.WriteIndentedLine(indentCount, generator.GetHeaderText(instance.GetScriptName())); content.WriteImports("UnityEngine"); using (new CurlyBrackets(content, ConstantGenerator.OutputFileNamespace, indentCount)) { using (new CurlyBrackets(content, "public static class " + FileName, indentCount)) { foreach (ConstGenSettings.Shader_ sd in instance.newProperties) { // write shader header name group content.WriteIndentedFormatLine(indentCount, "public static class {0}", generator.MakeIdentifier(sd.name)); using (new CurlyBrackets(content, indentCount)) { foreach (string propertyName in sd.properties) { // write properties content.WriteIndentedFormatLine(indentCount, "public const string _{0} = \"{1}\";", generator.MakeIdentifier(propertyName).Remove(0, 1), generator.EscapeDoubleQuote(propertyName)); } } content.WriteNewLine(); } } } }); // imports the output file when the generation method is through an update // so we can force recompile the editor // NOTE: for some reason AssetDatabase.Refresh() // doesn't immidiately trigger editor recompiling so this method is used instead if (instance.updateGeneration) { AssetDatabase.ImportAsset(FilePath); } }
private static void GenerateCode() { generator.GenerateCodeFile(FilePath, generator.GetOutputPath(), content => { WrappedInt indentCount = 0; // NOTE: indentCount is automatically increamented or decreamented by // ContentWriter methods // An indent is added when a new CurlyBrackets IDisposable instance is created // and removed everytime that IDisposable instance is disposed of // (when the control has excited from the using statement) content.WriteIndentedLine(indentCount, generator.GetHeaderText(instance.GetScriptName())); content.WriteImports("UnityEngine"); using (new CurlyBrackets(content, ConstantGenerator.OutputFileNamespace, indentCount)) { using (new CurlyBrackets(content, "public static class " + FileName, indentCount)) { foreach (ConstGenSettings.LayersCTRLR ctrlr in instance.newLayers) { // write layers animator header group content.WriteIndentedFormatLine(indentCount, "public static class {0}", generator.MakeIdentifier(ctrlr.name)); using (new CurlyBrackets(content, indentCount)) { int layerIndex = 0; foreach (string parameters in ctrlr.layers) { content.WriteIndentedFormatLine(indentCount, "public const int {0} = {1};", generator.MakeIdentifier(parameters), layerIndex); layerIndex++; } } content.WriteNewLine(); } } } }); }
private static void GenerateCode() { generator.GenerateCodeFile(FilePath, generator.GetOutputPath(), content => { WrappedInt indentCount = 0; // NOTE: indentCount is automatically increamented or decreamented by // ContentWriter methods // An indent is added when a new CurlyBrackets IDisposable instance is created // and removed everytime that IDisposable instance is disposed of // (when the control has excited from the using statement) content.WriteIndentedLine(indentCount, generator.GetHeaderText(instance.GetScriptName())); content.WriteImports("UnityEngine"); using (new CurlyBrackets(content, ConstantGenerator.OutputFileNamespace, indentCount)) { using (new CurlyBrackets(content, "public static class " + FileName, indentCount)) { int z = 0; foreach (string property in instance.newScenes) { // ex) assets/scenes/menu.unity -> menu var tail = property.Substring(property.LastIndexOf('/') + 1); var result = tail.Substring(0, tail.LastIndexOf('.')); content.WriteIndentedFormatLine(indentCount, "public const int {0} = {1};", generator.MakeIdentifier(result), z); z++; } } } }); }
private static void GenerateCode() { generator.GenerateCodeFile(FilePath, generator.GetOutputPath(), content => { WrappedInt indentCount = 0; // NOTE: indentCount is automatically increamented or decreamented by // ContentWriter methods // An indent is added when a new CurlyBrackets IDisposable instance is created // and removed everytime that IDisposable instance is disposed of // (when the control has excited from the using statement) content.WriteIndentedLine(indentCount, generator.GetHeaderText(instance.GetScriptName())); content.WriteImports("UnityEngine"); using (new CurlyBrackets(content, ConstantGenerator.OutputFileNamespace, indentCount)) { using (new CurlyBrackets(content, "public static class " + FileName, indentCount)) { // loop through all animators for (int i = 0; i < instance.newStateCTRLRS.Count; i++) { // cache current animator ConstGenSettings.StatesCTRLR animState = instance.newStateCTRLRS[i]; // write animator name header using (new CurlyBrackets(content, "public static class " + generator.MakeIdentifier(animState.name), indentCount)) { // loop through layers for (int i2 = 0; i2 < animState.animLayers.Count; i2++) { // cache current layer ConstGenSettings.AnimLayer animLayer = animState.animLayers[i2]; // write layer group header name using (new CurlyBrackets(content, "public static class " + generator.MakeIdentifier(animLayer.name) + "_L", indentCount)) { // loop through states for (int i3 = 0; i3 < animLayer.animStates.Count; i3++) { // cache current state ConstGenSettings.AnimState state_ = animLayer.animStates[i3]; // write state name group at header using (new CurlyBrackets(content, "public static class " + generator.MakeIdentifier(state_.name) + "_S", indentCount)) { // write state name content.WriteIndentedFormatLine(indentCount, "public const string name = @\"{0}\";", state_.name); // write state tag if present if (state_.tag != string.Empty && state_.tag != null) { content.WriteIndentedFormatLine(indentCount, "public const string tag = @\"{0}\";", state_.tag); } } } } } } } } } }); }