NG_/AVProVideo/Editor/Scripts/Components/MediaPlayerEditor_Audio.cs
2024-12-13 18:49:44 +08:00

87 lines
3.4 KiB
C#

using UnityEngine;
using UnityEditor;
//-----------------------------------------------------------------------------
// Copyright 2015-2022 RenderHeads Ltd. All rights reserved.
//-----------------------------------------------------------------------------
namespace RenderHeads.Media.AVProVideo.Editor
{
/// <summary>
/// Editor for the MediaPlayer component
/// </summary>
public partial class MediaPlayerEditor : UnityEditor.Editor
{
private SerializedProperty _propVolume;
private SerializedProperty _propBalance;
private SerializedProperty _propMuted;
private SerializedProperty _propAudioHeadTransform;
private SerializedProperty _propAudioEnableFocus;
private SerializedProperty _propAudioFocusOffLevelDB;
private SerializedProperty _propAudioFocusWidthDegrees;
private SerializedProperty _propAudioFocusTransform;
private void OnInspectorGUI_Audio()
{
if (EditorUtility.audioMasterMute)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.HelpBox("Audio is currently muted in Editor", MessageType.Warning, true);
if (GUILayout.Button("Unmute", GUILayout.ExpandHeight(true)))
{
EditorUtility.audioMasterMute = false;
UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); // To force the GameView audio mute toggle display state to update
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.BeginVertical(GUI.skin.box);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_propVolume, new GUIContent("Volume"));
if (EditorGUI.EndChangeCheck())
{
foreach (MediaPlayer player in this.targets)
{
player.AudioVolume = _propVolume.floatValue;
}
}
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_propBalance, new GUIContent("Balance"));
if (EditorGUI.EndChangeCheck())
{
foreach (MediaPlayer player in this.targets)
{
player.AudioBalance = _propBalance.floatValue;
}
}
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_propMuted, new GUIContent("Muted"));
if (EditorGUI.EndChangeCheck())
{
foreach (MediaPlayer player in this.targets)
{
player.AudioMuted = _propMuted.boolValue;
}
}
EditorGUILayout.EndVertical();
if (_showUltraOptions)
{
EditorGUILayout.BeginVertical(GUI.skin.box);
GUILayout.Label("Audio 360", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_propAudioHeadTransform, new GUIContent("Head Transform", "Set this to your head camera transform. Only currently used for Facebook Audio360"));
EditorGUILayout.PropertyField(_propAudioEnableFocus, new GUIContent("Enable Focus", "Enables focus control. Only currently used for Facebook Audio360"));
if (_propAudioEnableFocus.boolValue)
{
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"));
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"));
EditorGUILayout.PropertyField(_propAudioFocusTransform, new GUIContent("Focus Transform", "Set this to where you wish to focus on the video. Only currently used for Facebook Audio360"));
}
EditorGUILayout.EndVertical();
}
}
}
}