Class SoundPlayer
Audio component that can play a Soundy sound by using a SoundId.. It uses an AudioPlayer component to play the sound.
Namespace: Doozy.Runtime.Soundy
Assembly: cs.temp.dll.dll
Syntax
public class SoundPlayer : MonoBehaviour
Properties
audioPlayer
When playing, this is the audio player that is used to play the sound (is null when not playing)
Declaration
public AudioPlayer audioPlayer { get; }
Property Value
Type | Description |
---|---|
AudioPlayer |
followTarget
Transform that the sound played by this SoundPlayer will follow (if set)
Declaration
public Transform followTarget { get; set; }
Property Value
Type | Description |
---|---|
Transform |
id
Sound Id (library name + sound name) that this SoundPlayer is referencing
Declaration
public SoundId id { get; set; }
Property Value
Type | Description |
---|---|
SoundId |
outputAudioMixerGroup
AudioMixerGroup used by this SoundPlayer when playing a sound (can be null)
Declaration
public AudioMixerGroup outputAudioMixerGroup { get; }
Property Value
Type | Description |
---|---|
AudioMixerGroup |
playOnDisable
Play the sound on Disable
Declaration
public bool playOnDisable { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
playOnEnable
Play the sound on Enable
Declaration
public bool playOnEnable { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
playOnStart
Play the sound on Start
Declaration
public bool playOnStart { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
soundLibrary
SoundLibrary the SoundId is referencing (can be null)
Declaration
public SoundLibrary soundLibrary { get; }
Property Value
Type | Description |
---|---|
SoundLibrary |
soundObject
SoundObject the SoundId is referencing (can be null)
Declaration
public SoundObject soundObject { get; }
Property Value
Type | Description |
---|---|
SoundObject |
stopOnDestroy
Stop the sound on Destroy
Declaration
public bool stopOnDestroy { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
stopOnDisable
Stop the sound on Disable
Declaration
public bool stopOnDisable { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Get()
Create a new SoundPlayer GameObject and add a SoundPlayer component to it.
Declaration
public static SoundPlayer Get()
Returns
Type | Description |
---|---|
SoundPlayer | Newly created SoundPlayer component |
Play()
Play the loaded sound object. If the sound object is null or cannot play, nothing happens.
Declaration
public void Play()
ResetPlayer()
Clear the sound player and id and set everything to null. After this method is called, the sound player will not be able to play any sound until a new sound is set.
Declaration
public SoundPlayer ResetPlayer()
Returns
Type | Description |
---|---|
SoundPlayer | Self (useful for chaining) |
SetFollowTarget(Transform)
Set a target that the sound will follow while playing
Declaration
public SoundPlayer SetFollowTarget(Transform newFollowTarget)
Parameters
Type | Name | Description |
---|---|---|
Transform | newFollowTarget | Transform that the sound will follow |
Returns
Type | Description |
---|---|
SoundPlayer | Self (useful for chaining) |
SetSound(SoundId)
Set a new sound by providing the sound id
Declaration
public SoundPlayer SetSound(SoundId newSoundId)
Parameters
Type | Name | Description |
---|---|---|
SoundId | newSoundId | Sound Id (library name + sound name) |
Returns
Type | Description |
---|---|
SoundPlayer | Self (useful for chaining) |
SetSound(String, String)
Set a new sound by providing the sound library name and the sound name
Declaration
public SoundPlayer SetSound(string newLibraryName, string newSoundName)
Parameters
Type | Name | Description |
---|---|---|
String | newLibraryName | Sound Library Name where this sound is located |
String | newSoundName | Sound Name from the Sound Library |
Returns
Type | Description |
---|---|
SoundPlayer | Self (useful for chaining) |
Stop()
Stop the loaded sound object, if it is playing. If the sound object is null or cannot stop, nothing happens.
Declaration
public void Stop()