diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
| commit | c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch) | |
| tree | ee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs | |
| download | Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2 Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip | |
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs')
| -rw-r--r-- | Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs new file mode 100644 index 0000000..c5bdf8c --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Audio/AudioMixerProperties.cs @@ -0,0 +1,45 @@ +using System; +using UnityEngine.Audio; +using UnityEngine.Playables; + +namespace UnityEngine.Timeline +{ + [Serializable] + class AudioMixerProperties : PlayableBehaviour + { + [Range(0.0f, 1.0f)] + public float volume = 1.0f; + + [Range(-1.0f, 1.0f)] + public float stereoPan = 0.0f; + + [Range(0.0f, 1.0f)] + public float spatialBlend = 0.0f; + + public override void PrepareFrame(Playable playable, FrameData info) + { + if (!playable.IsValid() || !playable.IsPlayableOfType<AudioMixerPlayable>()) + return; + + var inputCount = playable.GetInputCount(); + + for (int i = 0; i < inputCount; ++i) + { + if (playable.GetInputWeight(i) > 0.0f) + { + var input = playable.GetInput(i); + + if (input.IsValid() && input.IsPlayableOfType<AudioClipPlayable>()) + { + var audioClipPlayable = (AudioClipPlayable)input; + var audioClipProperties = input.GetHandle().GetObject<AudioClipProperties>(); + + audioClipPlayable.SetVolume(Mathf.Clamp01(volume * audioClipProperties.volume)); + audioClipPlayable.SetStereoPan(Mathf.Clamp(stereoPan, -1.0f, 1.0f)); + audioClipPlayable.SetSpatialBlend(Mathf.Clamp01(spatialBlend)); + } + } + } + } + } +} |
