Class PlaybackBehavior
Helper serialized class to display in Unity inspector. Generates details for fade-ins and fade-outs.
Namespace: OmiyaGames.Audio
Assembly: cs.temp.dll.dll
Syntax
[Serializable]
public class PlaybackBehavior
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: 1.0.0 Date: 6/23/2022 Author: Taro Omiya | Initial draft. |
Version: 1.1.0 Date: 6/30/2022 Author: Taro Omiya | Adding new property, IsPausedOnTimeStop. |
Constructors
PlaybackBehavior(PlaybackBehavior.FadeBehavior, Double, Boolean, Boolean)
Constructs a new instance with default arguments.
Declaration
public PlaybackBehavior(PlaybackBehavior.FadeBehavior behavior = PlaybackBehavior.FadeBehavior.DoNothing, double fadeDurationSeconds = 0.5, bool alwaysRestart = false, bool isPausedOnTimeStop = false)
Parameters
Type | Name | Description |
---|---|---|
PlaybackBehavior.FadeBehavior | behavior | Sets default Behavior. |
Double | fadeDurationSeconds | Sets default FadeDurationSeconds. |
Boolean | alwaysRestart | Sets default AlwaysRestart. |
Boolean | isPausedOnTimeStop | Sets default IsPausedOnTimeStop. |
Fields
DEFAULT_FADE_DURATION
Declaration
public const float DEFAULT_FADE_DURATION = 0.5F
Field Value
Type | Description |
---|---|
Single |
Properties
AlwaysRestart
If true, restarts playing AudioFile even if it's already playing in the background.
Declaration
public bool AlwaysRestart { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
This property is set in the Unity Inspector.
AudioFile
Gets the audio to fade in.
Declaration
public AssetRefSerialized<BackgroundAudio> AudioFile { get; }
Property Value
Type | Description |
---|---|
AssetRefSerialized<BackgroundAudio> |
Remarks
This property is set in the Unity Inspector.
Behavior
Gets the action to take.
Declaration
public PlaybackBehavior.FadeBehavior Behavior { get; }
Property Value
Type | Description |
---|---|
PlaybackBehavior.FadeBehavior |
Remarks
This property is set in the Unity Inspector.
FadeDurationSeconds
Gets how long to perform the fade-in or fade-out, in seconds.
Normalized by
Declaration
public double FadeDurationSeconds { get; }
Property Value
Type | Description |
---|---|
Double |
Remarks
This property is set in the Unity Inspector.
IsPausedOnTimeStop
If true, pauses the
AudioFile when
Declaration
public bool IsPausedOnTimeStop { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
This property is set in the Unity Inspector.
Methods
GetFadeInArgs()
Generates a fade-in arguments based on this instance's properties.
Declaration
public FadeInArgs GetFadeInArgs()
Returns
Type | Description |
---|---|
FadeInArgs | The fade-in arguments using FadeDurationSeconds and AlwaysRestart. |
GetFadeOutArgs()
Generates a fade-out arguments based on this instance's properties.
Declaration
public FadeOutArgs GetFadeOutArgs()
Returns
Type | Description |
---|---|
FadeOutArgs | The fade-in arguments using FadeDurationSeconds. |
StartCoroutine(MonoBehaviour, AudioLayer.Background, AudioLayer.Background.OnCoroutineFinished)
Starts the
Declaration
public Coroutine StartCoroutine(MonoBehaviour script, AudioLayer.Background audioLayer, AudioLayer.Background.OnCoroutineFinished onFinish = null)
Parameters
Type | Name | Description |
---|---|---|
MonoBehaviour | script | The script to run this |
AudioLayer.Background | audioLayer | |
AudioLayer.Background.OnCoroutineFinished | onFinish | Invoked at the end of the |
Returns
Type | Description |
---|---|
Coroutine | The |