MediaPlayerEditor_Audio.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using UnityEngine;
  2. using UnityEditor;
  3. //-----------------------------------------------------------------------------
  4. // Copyright 2015-2022 RenderHeads Ltd. All rights reserved.
  5. //-----------------------------------------------------------------------------
  6. namespace RenderHeads.Media.AVProVideo.Editor
  7. {
  8. /// <summary>
  9. /// Editor for the MediaPlayer component
  10. /// </summary>
  11. public partial class MediaPlayerEditor : UnityEditor.Editor
  12. {
  13. private SerializedProperty _propVolume;
  14. private SerializedProperty _propBalance;
  15. private SerializedProperty _propMuted;
  16. private SerializedProperty _propAudioHeadTransform;
  17. private SerializedProperty _propAudioEnableFocus;
  18. private SerializedProperty _propAudioFocusOffLevelDB;
  19. private SerializedProperty _propAudioFocusWidthDegrees;
  20. private SerializedProperty _propAudioFocusTransform;
  21. private void OnInspectorGUI_Audio()
  22. {
  23. if (EditorUtility.audioMasterMute)
  24. {
  25. EditorGUILayout.BeginHorizontal();
  26. EditorGUILayout.HelpBox("Audio is currently muted in Editor", MessageType.Warning, true);
  27. if (GUILayout.Button("Unmute", GUILayout.ExpandHeight(true)))
  28. {
  29. EditorUtility.audioMasterMute = false;
  30. UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); // To force the GameView audio mute toggle display state to update
  31. }
  32. EditorGUILayout.EndHorizontal();
  33. }
  34. EditorGUILayout.BeginVertical(GUI.skin.box);
  35. EditorGUI.BeginChangeCheck();
  36. EditorGUILayout.PropertyField(_propVolume, new GUIContent("Volume"));
  37. if (EditorGUI.EndChangeCheck())
  38. {
  39. foreach (MediaPlayer player in this.targets)
  40. {
  41. player.AudioVolume = _propVolume.floatValue;
  42. }
  43. }
  44. EditorGUI.BeginChangeCheck();
  45. EditorGUILayout.PropertyField(_propBalance, new GUIContent("Balance"));
  46. if (EditorGUI.EndChangeCheck())
  47. {
  48. foreach (MediaPlayer player in this.targets)
  49. {
  50. player.AudioBalance = _propBalance.floatValue;
  51. }
  52. }
  53. EditorGUI.BeginChangeCheck();
  54. EditorGUILayout.PropertyField(_propMuted, new GUIContent("Muted"));
  55. if (EditorGUI.EndChangeCheck())
  56. {
  57. foreach (MediaPlayer player in this.targets)
  58. {
  59. player.AudioMuted = _propMuted.boolValue;
  60. }
  61. }
  62. EditorGUILayout.EndVertical();
  63. if (_showUltraOptions)
  64. {
  65. EditorGUILayout.BeginVertical(GUI.skin.box);
  66. GUILayout.Label("Audio 360", EditorStyles.boldLabel);
  67. EditorGUILayout.PropertyField(_propAudioHeadTransform, new GUIContent("Head Transform", "Set this to your head camera transform. Only currently used for Facebook Audio360"));
  68. EditorGUILayout.PropertyField(_propAudioEnableFocus, new GUIContent("Enable Focus", "Enables focus control. Only currently used for Facebook Audio360"));
  69. if (_propAudioEnableFocus.boolValue)
  70. {
  71. EditorGUILayout.PropertyField(_propAudioFocusOffLevelDB, new GUIContent("Off Focus Level DB", "Sets the off-focus level in DB, with the range being between -24 to 0 DB. Only currently used for Facebook Audio360"));
  72. EditorGUILayout.PropertyField(_propAudioFocusWidthDegrees, new GUIContent("Focus Width Degrees", "Set the focus width in degrees, with the range being between 40 and 120 degrees. Only currently used for Facebook Audio360"));
  73. EditorGUILayout.PropertyField(_propAudioFocusTransform, new GUIContent("Focus Transform", "Set this to where you wish to focus on the video. Only currently used for Facebook Audio360"));
  74. }
  75. EditorGUILayout.EndVertical();
  76. }
  77. }
  78. }
  79. }