UICreateRedDotKeyGet.cs 812 B

123456789101112131415161718192021222324252627282930313233
  1. #if UNITY_EDITOR
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace YIUIFramework.Editor
  5. {
  6. internal static class UICreateRedDotKeyGet
  7. {
  8. public static string Get(List<RedDotKeyData> dataList)
  9. {
  10. var sb = SbPool.Get();
  11. foreach (var data in dataList)
  12. {
  13. data.AddKeyData(sb);
  14. }
  15. return SbPool.PutAndToStr(sb);
  16. }
  17. private const string m_EnumContent = @"
  18. [LabelText(""{0}"")]
  19. public const int Key{1} = {1};
  20. ";
  21. private static void AddKeyData(this RedDotKeyData data, StringBuilder sb)
  22. {
  23. var des = string.IsNullOrEmpty(data.Des) ? data.Id.ToString() : data.Des;
  24. sb.AppendFormat(m_EnumContent, des, data.Id);
  25. }
  26. }
  27. }
  28. #endif