Bez popisu
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.

TimelineHelpURLAttribute.cs 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if UNITY_EDITOR && UNITY_2021_1_OR_NEWER
  2. #define CAN_USE_CUSTOM_HELP_URL
  3. #endif
  4. using System;
  5. using System.Diagnostics;
  6. using UnityEngine;
  7. namespace UnityEngine.Timeline
  8. {
  9. #if CAN_USE_CUSTOM_HELP_URL
  10. using UnityEditor.PackageManager;
  11. [Conditional("UNITY_EDITOR")]
  12. class TimelineHelpURLAttribute : HelpURLAttribute
  13. {
  14. const string k_BaseURL = "https://docs.unity3d.com/Packages/com.unity.timeline@";
  15. const string k_MidURL = "/api/";
  16. const string k_EndURL = ".html";
  17. const string k_FallbackVersion = "latest";
  18. static readonly string k_PackageVersion;
  19. static TimelineHelpURLAttribute()
  20. {
  21. PackageInfo packageInfo = PackageInfo.FindForAssembly(typeof(TimelineAsset).Assembly);
  22. k_PackageVersion = packageInfo == null ? k_FallbackVersion : packageInfo.version.Substring(0, 3);
  23. }
  24. public TimelineHelpURLAttribute(Type type)
  25. : base(HelpURL(type)) {}
  26. static string HelpURL(Type type)
  27. {
  28. return $"{k_BaseURL}{k_PackageVersion}{k_MidURL}{type.FullName}{k_EndURL}";
  29. }
  30. }
  31. #else //HelpURL attribute is `sealed` in previous Unity versions
  32. [Conditional("UNITY_EDITOR")]
  33. class TimelineHelpURLAttribute : Attribute
  34. {
  35. public TimelineHelpURLAttribute(Type type) { }
  36. }
  37. #endif
  38. }