No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BoltFlowNameUtility.cs 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Linq;
  3. namespace Unity.VisualScripting
  4. {
  5. public static class BoltFlowNameUtility
  6. {
  7. [Obsolete("This method is obsolete. Please use the new UnitTitle(unitType, short, includeStatus) instead.")]
  8. public static string UnitTitle(Type unitType, bool @short)
  9. {
  10. if (@short)
  11. {
  12. var shortTitle = unitType.GetAttribute<UnitShortTitleAttribute>()?.title;
  13. if (shortTitle != null)
  14. {
  15. return shortTitle;
  16. }
  17. }
  18. var title = unitType.GetAttribute<UnitTitleAttribute>()?.title;
  19. if (title != null)
  20. {
  21. return title;
  22. }
  23. return unitType.HumanName();
  24. }
  25. public static string UnitTitle(Type unitType, bool @short, bool includeStatus)
  26. {
  27. var suffix = string.Empty;
  28. if (includeStatus && Attribute.IsDefined(unitType, typeof(ObsoleteAttribute)))
  29. suffix = " (Deprecated)";
  30. if (@short)
  31. {
  32. var shortTitle = unitType.GetAttribute<UnitShortTitleAttribute>()?.title;
  33. if (shortTitle != null)
  34. {
  35. return $"{shortTitle} {suffix}";
  36. }
  37. }
  38. var title = unitType.GetAttribute<UnitTitleAttribute>()?.title;
  39. return title != null ? $"{title} {suffix}" : $"{unitType.HumanName()} {suffix}";
  40. }
  41. public static string UnitPreviousTitle(Type unitType)
  42. {
  43. var title = unitType.GetAttribute<RenamedFromAttribute>()?.previousName.Split('.').Last();
  44. return title ?? string.Empty;
  45. }
  46. }
  47. }