Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System.Text;
- using UnityEditor;
- public class Creator
- {
- private const string PATH = "Assets/Enum.cs";
- private const int COUNT = 200;
- [MenuItem( "Tools/Hoge" )]
- private static void Hoge()
- {
- var sb = new StringBuilder();
- sb.AppendLine( "using System.Collections.Generic;" );
- sb.AppendLine();
- for ( int i = 0; i < COUNT; i++ )
- {
- sb.AppendFormat( @"public enum Example{0} {{ VALUE_1, VALUE_2, VALUE_3, VALUE_4, VALUE_5 }}", i.ToString() ).AppendLine();
- }
- sb.AppendLine( "public class Hoge" );
- sb.AppendLine( "{" );
- for ( int i = 0; i < COUNT; i++ )
- {
- sb.Append( "\t" ).AppendFormat( @"Dictionary<Example{0}, string> m_table{0} = new Dictionary<Example{0}, string>();", i.ToString() ).AppendLine();
- //sb.Append( "\t" ).AppendFormat( @"Dictionary<Example0, string> m_table{0} = new Dictionary<Example0, string>();", i.ToString() ).AppendLine();
- //sb.Append( "\t" ).AppendFormat( @"Dictionary<int, string> m_table{0} = new Dictionary<int, string>();", i.ToString() ).AppendLine();
- }
- sb.AppendLine( "}" );
- var directoryName = Path.GetDirectoryName( PATH );
- if ( !Directory.Exists( directoryName ) )
- {
- Directory.CreateDirectory( directoryName );
- }
- File.WriteAllText( PATH, sb.ToString(), Encoding.UTF8 );
- AssetDatabase.Refresh( ImportAssetOptions.ImportRecursive );
- }
- }
Add Comment
Please, Sign In to add comment