MenuEntryAttribute.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace UnityEditor.Timeline
  6. {
  7. /// <summary>
  8. /// Used to indicate path and priority of classes that are auto added to the menu
  9. /// </summary>
  10. [AttributeUsage(AttributeTargets.Class)]
  11. internal class MenuEntryAttribute : Attribute
  12. {
  13. public readonly int priority;
  14. public readonly string name;
  15. public readonly string subMenuPath;
  16. public MenuEntryAttribute(string path, int priority)
  17. {
  18. path = path ?? string.Empty;
  19. path = L10n.Tr(path);
  20. this.priority = priority;
  21. int index = path.LastIndexOf('/');
  22. if (index >= 0)
  23. {
  24. name = (index == path.Length - 1) ? string.Empty : path.Substring(index + 1);
  25. subMenuPath = path.Substring(0, index + 1);
  26. }
  27. else
  28. {
  29. name = path;
  30. subMenuPath = string.Empty;
  31. }
  32. }
  33. }
  34. }