DisplayNameHelper.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Text;
  2. using UnityEngine.Playables;
  3. namespace UnityEditor.Timeline
  4. {
  5. static class DisplayNameHelper
  6. {
  7. static readonly string k_NoAssetDisplayName = L10n.Tr("<No Asset>");
  8. static readonly string k_ReadOnlyDisplayName = L10n.Tr("[Read Only]");
  9. static readonly StringBuilder k_StringBuilder = new StringBuilder();
  10. public static string GetDisplayName(ISequenceState sequence)
  11. {
  12. string displayName = sequence.director != null ? GetDisplayName(sequence.director) : GetDisplayName(sequence.asset);
  13. if (sequence.asset != null && sequence.isReadOnly)
  14. displayName += " " + k_ReadOnlyDisplayName;
  15. return displayName;
  16. }
  17. public static string GetDisplayName(PlayableAsset asset)
  18. {
  19. return asset != null ? asset.name : k_NoAssetDisplayName;
  20. }
  21. public static string GetDisplayName(PlayableDirector director)
  22. {
  23. k_StringBuilder.Length = 0;
  24. k_StringBuilder.Append(GetDisplayName(director.playableAsset));
  25. k_StringBuilder.Append(" (").Append(director.name).Append(')');
  26. return k_StringBuilder.ToString();
  27. }
  28. }
  29. }