Class AudioLayer.Background
Audio category applicable to ones predominately used in the background, i.e. music and ambience.
Inherited Members
Namespace: OmiyaGames.Audio
Assembly: cs.temp.dll.dll
Syntax
[Serializable]
public class Background : AudioLayer.SubLayer
Remarks
Copyright (c) 2022 Omiya Games Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Revision | Description |
---|---|
Version: 0.1.0-exp.1 Date: 2/27/2022 Author: Taro Omiya | Initial draft. |
Version: 1.0.0 Date: 6/3/2022 Author: Taro Omiya |
Adding properties and methods that utilizes
|
Properties
CurrentFile
Grabs the currently-playing audio file from History.
Declaration
public AssetRef<BackgroundAudio> CurrentFile { get; }
Property Value
Type | Description |
---|---|
AssetRef<BackgroundAudio> |
CurrentPlayer
Grabs the currently-playing audio file from History.
Declaration
public BackgroundAudio.Player CurrentPlayer { get; }
Property Value
Type | Description |
---|---|
BackgroundAudio.Player |
History
Gets the history of BackgroundAudio played.
Declaration
public AudioHistory History { get; }
Property Value
Type | Description |
---|---|
AudioHistory |
Remarks
No properties adds BackgroundAudio
to this history tracker automatically. As such, if you're
not using the helper methods within this class (e.g.
MixerGroupManager
Gets the manager of
Declaration
public MixerGroupManager MixerGroupManager { get; }
Property Value
Type | Description |
---|---|
MixerGroupManager |
PlayerManager
Gets the manager of BackgroundAudio and the BackgroundAudio.Players generated by them.
Declaration
public AudioPlayerManager PlayerManager { get; }
Property Value
Type | Description |
---|---|
AudioPlayerManager |
Methods
CreateManagers(Transform, String, AnimationCurve)
Sets up PlayerManager and MixerGroupManager. Required to be called with OmiyaGames.Audio.AudioLayer.Setup.
Declaration
public void CreateManagers(Transform parentTransform, string gameObjectName, AnimationCurve percentToDbCurve)
Parameters
Type | Name | Description |
---|---|---|
Transform | parentTransform | The transform to create a new |
String | gameObjectName | The name of the newly created |
AnimationCurve | percentToDbCurve | The curve used to convert a fraction from |
FadeInCurrentPlayingCoroutine(FadeInArgs, AudioLayer.Background.OnCoroutineFinished)
Fades in the currently-playing audio in this layer.
Declaration
public IEnumerator FadeInCurrentPlayingCoroutine(FadeInArgs fadeInArgs = null, AudioLayer.Background.OnCoroutineFinished onFinish = null)
Parameters
Type | Name | Description |
---|---|---|
FadeInArgs | fadeInArgs | |
AudioLayer.Background.OnCoroutineFinished | onFinish |
Returns
Type | Description |
---|---|
IEnumerator |
FadeOutCurrentPlaying(FadeOutArgs, BackgroundAudio.Player[])
Fades out the currently-playing audio in this layer.
Declaration
public void FadeOutCurrentPlaying(FadeOutArgs fadeOutArgs = null, params BackgroundAudio.Player[] except)
Parameters
Type | Name | Description |
---|---|---|
FadeOutArgs | fadeOutArgs | Details on how to fade-out, e.g. how long it should last. |
BackgroundAudio.Player[] | except | Players not to fade out. |
GetCurrentPlayer(AudioPlayerManager.AudioState)
Grab the first player associated with CurrentFile
Declaration
public BackgroundAudio.Player GetCurrentPlayer(AudioPlayerManager.AudioState state = AudioPlayerManager.AudioState.All)
Parameters
Type | Name | Description |
---|---|---|
AudioPlayerManager.AudioState | state | The state to filter players by. |
Returns
Type | Description |
---|---|
BackgroundAudio.Player | The first BackgroundAudio.Players with the same state
as |
Remarks
Order (and thus, what's determined as "the first player") is
dependent upon
GetCurrentPlayers(AudioPlayerManager.AudioState)
Grab all the players associated with CurrentFile
Declaration
public List<BackgroundAudio.Player> GetCurrentPlayers(AudioPlayerManager.AudioState state = AudioPlayerManager.AudioState.All)
Parameters
Type | Name | Description |
---|---|---|
AudioPlayerManager.AudioState | state | The state to filter players by. |
Returns
Type | Description |
---|---|
List<BackgroundAudio.Player> | All the currently active BackgroundAudio.Players
with the same state as |
PlayNextCoroutine(AssetRef<BackgroundAudio>, FadeInArgs, FadeOutArgs, AudioLayer.Background.OnCoroutineFinished)
Coroutine to fade in the next background audio. Also adds
audioClip
into the history if played.
Declaration
public IEnumerator PlayNextCoroutine(AssetRef<BackgroundAudio> audioClip, FadeInArgs fadeInArgs = null, FadeOutArgs fadeOutArgs = null, AudioLayer.Background.OnCoroutineFinished onFinish = null)
Parameters
Type | Name | Description |
---|---|---|
AssetRef<BackgroundAudio> | audioClip | The clip to play |
FadeInArgs | fadeInArgs | Details on how to fade-in, e.g. how long it should last. |
FadeOutArgs | fadeOutArgs | Details on how to fade-out, e.g. how long it should last. |
AudioLayer.Background.OnCoroutineFinished | onFinish | Triggers as soon as this coroutine finishes, with a reference to the player that will be faded in. |
Returns
Type | Description |
---|---|
IEnumerator | A coroutine for loading |
Remarks
This coroutine needs to be yielded on regardless of whether
audioClip
points to an addressable or not.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If |
PlayPreviousCoroutine(FadeInArgs, FadeOutArgs, AudioLayer.Background.OnCoroutineFinished)
Coroutine to fade in the previous background audio in History, if any. Also removes the newest clip from the history, if played.
Declaration
public IEnumerator PlayPreviousCoroutine(FadeInArgs fadeInArgs = null, FadeOutArgs fadeOutArgs = null, AudioLayer.Background.OnCoroutineFinished onFinish = null)
Parameters
Type | Name | Description |
---|---|---|
FadeInArgs | fadeInArgs | Details on how to fade-in, e.g. how long it should last. |
FadeOutArgs | fadeOutArgs | Details on how to fade-out, e.g. how long it should last. |
AudioLayer.Background.OnCoroutineFinished | onFinish | Triggers as soon as this coroutine finishes, with a reference
to the player that will be faded in. The parameter will be
null if |
Returns
Type | Description |
---|---|
IEnumerator | A coroutine for loading the previous BackgroundAudio. |
Remarks
This coroutine needs to be yielded on regardless of whether the previous clip points to an addressable or not.