Guest User

Untitled

a guest
Dec 13th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System.IO;
  2. using System.Text;
  3. using UnityEditor;
  4.  
  5. public class Creator
  6. {
  7. private const string PATH = "Assets/Enum.cs";
  8. private const int COUNT = 200;
  9.  
  10. [MenuItem( "Tools/Hoge" )]
  11. private static void Hoge()
  12. {
  13. var sb = new StringBuilder();
  14.  
  15. sb.AppendLine( "using System.Collections.Generic;" );
  16. sb.AppendLine();
  17.  
  18. for ( int i = 0; i < COUNT; i++ )
  19. {
  20. sb.AppendFormat( @"public enum Example{0} {{ VALUE_1, VALUE_2, VALUE_3, VALUE_4, VALUE_5 }}", i.ToString() ).AppendLine();
  21. }
  22.  
  23. sb.AppendLine( "public class Hoge" );
  24. sb.AppendLine( "{" );
  25.  
  26. for ( int i = 0; i < COUNT; i++ )
  27. {
  28. sb.Append( "\t" ).AppendFormat( @"Dictionary<Example{0}, string> m_table{0} = new Dictionary<Example{0}, string>();", i.ToString() ).AppendLine();
  29. //sb.Append( "\t" ).AppendFormat( @"Dictionary<Example0, string> m_table{0} = new Dictionary<Example0, string>();", i.ToString() ).AppendLine();
  30. //sb.Append( "\t" ).AppendFormat( @"Dictionary<int, string> m_table{0} = new Dictionary<int, string>();", i.ToString() ).AppendLine();
  31. }
  32.  
  33. sb.AppendLine( "}" );
  34.  
  35. var directoryName = Path.GetDirectoryName( PATH );
  36. if ( !Directory.Exists( directoryName ) )
  37. {
  38. Directory.CreateDirectory( directoryName );
  39. }
  40.  
  41. File.WriteAllText( PATH, sb.ToString(), Encoding.UTF8 );
  42. AssetDatabase.Refresh( ImportAssetOptions.ImportRecursive );
  43. }
  44. }
Add Comment
Please, Sign In to add comment