-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c12d0e4
commit b1c4e41
Showing
6 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// © 2024 Nikolay Melnikov <n.melnikov@depra.org> | ||
|
||
using Depra.SerializeReference.Extensions; | ||
using Depra.Sound.Clip; | ||
using Depra.Sound.Parameter; | ||
using UnityEngine; | ||
using static Depra.Sound.Module; | ||
|
||
namespace Depra.Sound.Source | ||
{ | ||
[AddComponentMenu(MENU_PATH + nameof(AudioSourceProxy), DEFAULT_ORDER)] | ||
public sealed class AudioSourceProxy : MonoBehaviour, IAudioSource | ||
{ | ||
[SerializeReferenceDropdown] | ||
[UnityEngine.SerializeReference] | ||
private IAudioSource _audioSource; | ||
|
||
event IAudioSource.PlayDelegate IAudioSource.Started | ||
{ | ||
add => _audioSource.Started += value; | ||
remove => _audioSource.Started -= value; | ||
} | ||
|
||
event IAudioSource.StopDelegate IAudioSource.Stopped | ||
{ | ||
add => _audioSource.Stopped += value; | ||
remove => _audioSource.Stopped -= value; | ||
} | ||
|
||
bool IAudioSource.IsPlaying => _audioSource.IsPlaying; | ||
|
||
IAudioClipParameters IAudioSource.Parameters => _audioSource.Parameters; | ||
|
||
void IAudioSource.Stop() => _audioSource.Stop(); | ||
|
||
void IAudioSource.Play(IAudioClip clip) => _audioSource.Play(clip); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// © 2024 Nikolay Melnikov <n.melnikov@depra.org> | ||
|
||
using System; | ||
using Depra.Sound.Clip; | ||
using Depra.Sound.Parameter; | ||
using UnityEngine; | ||
|
||
namespace Depra.Sound.Source | ||
{ | ||
[Serializable] | ||
public sealed class SceneAudioSourceRef : IAudioSource | ||
{ | ||
[SerializeField] private GameObject _gameObject; | ||
private IAudioSource _audioSource; | ||
|
||
private IAudioSource AudioSource => _audioSource ??= _gameObject.GetComponent<IAudioSource>(); | ||
|
||
event IAudioSource.PlayDelegate IAudioSource.Started | ||
{ | ||
add => AudioSource.Started += value; | ||
remove => AudioSource.Started -= value; | ||
} | ||
|
||
event IAudioSource.StopDelegate IAudioSource.Stopped | ||
{ | ||
add => AudioSource.Stopped += value; | ||
remove => AudioSource.Stopped -= value; | ||
} | ||
|
||
bool IAudioSource.IsPlaying => AudioSource.IsPlaying; | ||
|
||
IAudioClipParameters IAudioSource.Parameters => AudioSource?.Parameters; | ||
|
||
void IAudioSource.Stop() => AudioSource?.Stop(); | ||
|
||
void IAudioSource.Play(IAudioClip clip) => AudioSource?.Play(clip); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters