RecorderOptions.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using JetBrains.Annotations;
  2. namespace UnityEditor.Recorder
  3. {
  4. /// <summary>
  5. /// Options class for the Recorder
  6. /// </summary>
  7. public static class RecorderOptions
  8. {
  9. const string k_VerboseModeMenuItem = RecorderWindow.MenuRoot + "Options/Verbose Mode";
  10. const string k_ShowRecorderGameObject = RecorderWindow.MenuRoot + "Options/Show Recorder GameObject";
  11. const string k_ShowLegacyModeMenuItem = RecorderWindow.MenuRoot + "Options/Show Legacy Recorders";
  12. const string k_ExitPayModeItem = RecorderWindow.MenuRoot + "Options/Exit PlayMode";
  13. const string k_RecorderPanelWidth = RecorderWindow.MenuRoot + "Options/Recorder Panel Width";
  14. const string k_SelectedRecorderIndex = RecorderWindow.MenuRoot + "Options/Selected Recorder Index";
  15. /// <summary>
  16. /// If true, the recorder will log additional recording steps into the Console.
  17. /// </summary>
  18. public static bool VerboseMode
  19. {
  20. get { return EditorPrefs.GetBool(k_VerboseModeMenuItem, false); }
  21. set { EditorPrefs.SetBool(k_VerboseModeMenuItem, value); }
  22. }
  23. /// <summary>
  24. /// The recoder uses a "Unity-RecorderSessions" GameObject to store Scene references and manage recording sessions.
  25. /// If true, this GameObject will be visible in the Scene Hierarchy.
  26. /// </summary>
  27. public static bool ShowRecorderGameObject
  28. {
  29. get { return EditorPrefs.GetBool(k_ShowRecorderGameObject, false); }
  30. set
  31. {
  32. EditorPrefs.SetBool(k_ShowRecorderGameObject, value);
  33. UnityHelpers.SetGameObjectsVisibility(value);
  34. }
  35. }
  36. /// <summary>
  37. /// If true, legacy recorders will be displayed in the "Add New Recorder" menu.
  38. /// Legacy recorders are deprecated and will be removed from the Unity Recorder in future releases.
  39. /// </summary>
  40. public static bool ShowLegacyRecorders
  41. {
  42. get { return EditorPrefs.GetBool(k_ShowLegacyModeMenuItem, false); }
  43. set { EditorPrefs.SetBool(k_ShowLegacyModeMenuItem, value); }
  44. }
  45. internal static bool exitPlayMode
  46. {
  47. get { return EditorPrefs.GetBool(k_ExitPayModeItem, false); }
  48. set { EditorPrefs.SetBool(k_ExitPayModeItem, value); }
  49. }
  50. internal static float recorderPanelWith
  51. {
  52. get { return EditorPrefs.GetFloat(k_RecorderPanelWidth, 0); }
  53. set { EditorPrefs.SetFloat(k_RecorderPanelWidth, value); }
  54. }
  55. internal static int selectedRecorderIndex
  56. {
  57. get { return EditorPrefs.GetInt(k_SelectedRecorderIndex, 0); }
  58. set { EditorPrefs.SetInt(k_SelectedRecorderIndex, value); }
  59. }
  60. [MenuItem(k_VerboseModeMenuItem, false, RecorderWindow.MenuRootIndex + 200)]
  61. static void ToggleDebugMode()
  62. {
  63. var value = !VerboseMode;
  64. EditorPrefs.SetBool(k_VerboseModeMenuItem, value);
  65. VerboseMode = value;
  66. }
  67. [MenuItem(k_VerboseModeMenuItem, true)]
  68. static bool ToggleDebugModeValidate()
  69. {
  70. Menu.SetChecked(k_VerboseModeMenuItem, VerboseMode);
  71. return true;
  72. }
  73. [MenuItem(k_ShowRecorderGameObject, false, RecorderWindow.MenuRootIndex + 200)]
  74. static void ToggleShowRecorderGameObject()
  75. {
  76. var value = !ShowRecorderGameObject;
  77. EditorPrefs.SetBool(k_ShowRecorderGameObject, value);
  78. ShowRecorderGameObject = value;
  79. }
  80. [MenuItem(k_ShowRecorderGameObject, true)]
  81. static bool ToggleShowRecorderGameObjectValidate()
  82. {
  83. Menu.SetChecked(k_ShowRecorderGameObject, ShowRecorderGameObject);
  84. return true;
  85. }
  86. [MenuItem(k_ShowLegacyModeMenuItem, false, RecorderWindow.MenuRootIndex + 200)]
  87. static void ToggleShowLegacyRecorders()
  88. {
  89. var value = !ShowLegacyRecorders;
  90. EditorPrefs.SetBool(k_ShowLegacyModeMenuItem, value);
  91. ShowLegacyRecorders = value;
  92. }
  93. [MenuItem(k_ShowLegacyModeMenuItem, true)]
  94. static bool ToggleShowLegacyRecordersValidate()
  95. {
  96. Menu.SetChecked(k_ShowLegacyModeMenuItem, ShowLegacyRecorders);
  97. return true;
  98. }
  99. }
  100. [UsedImplicitly]
  101. static class Options
  102. {
  103. // This variable is used to select how we capture the final image from the
  104. // render pipeline, with the legacy render pipeline this variable is set to false
  105. // with the scriptable render pipeline the CameraCaptureBride
  106. // inside the SRP will reflection to set this variable to true, this will in turn
  107. // enable using the CameraInput inputStrategy CaptureCallbackInputStrategy
  108. //
  109. // This variable is set through reflection by SRP. Everything is matching very strictly: all flags are mandatory as well as the name.
  110. public static bool useCameraCaptureCallbacks = false;
  111. }
  112. }