-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Thundernerd/develop
v2.0.0
- Loading branch information
Showing
15 changed files
with
141 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.CodeDom; | ||
using System.Linq; | ||
using System.Reflection; | ||
using UnityEditor; | ||
using UnityEditorInternal; | ||
using UnityEngine; | ||
|
||
namespace TNRD.CodeGeneration.Tags | ||
{ | ||
public class TagGenerator : ICodeGenerator | ||
{ | ||
[MenuItem("TNRD/Code Generation/Tags")] | ||
private static void Execute() | ||
{ | ||
TagGenerator generator = new TagGenerator(); | ||
generator.Generate(); | ||
} | ||
|
||
public void Generate() | ||
{ | ||
string[] tags = InternalEditorUtility.tags | ||
.OrderBy(x => x) | ||
.ToArray(); | ||
|
||
CodeCompileUnit compileUnit = new CodeCompileUnit(); | ||
CodeNamespace codeNamespace = new CodeNamespace(); | ||
CodeTypeDeclaration classDeclaration = new CodeTypeDeclaration("Tags") | ||
{ | ||
IsClass = true, | ||
TypeAttributes = TypeAttributes.Public | TypeAttributes.Sealed | ||
}; | ||
|
||
foreach (string tag in tags) | ||
{ | ||
CodeMemberField field = new CodeMemberField | ||
{ | ||
Attributes = MemberAttributes.Public | MemberAttributes.Const, | ||
Name = Utilities.GetScreamName(tag), | ||
Type = new CodeTypeReference(typeof(string)), | ||
InitExpression = new CodePrimitiveExpression(tag) | ||
}; | ||
classDeclaration.Members.Add(field); | ||
} | ||
|
||
codeNamespace.Types.Add(classDeclaration); | ||
compileUnit.Namespaces.Add(codeNamespace); | ||
|
||
Utilities.GenerateToFile(compileUnit, Application.dataPath + "/Generated", "Tags.cs"); | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.