diff --git a/Assets/Scripts/Bootstrap.cs b/Assets/Scripts/Bootstrap.cs index e1db3c9..34b64d3 100644 --- a/Assets/Scripts/Bootstrap.cs +++ b/Assets/Scripts/Bootstrap.cs @@ -126,4 +126,14 @@ public void Cleanup() previewLoader.Cleanup(); } + + public void EnableSound() + { + previewLoader.EnableSound(); + } + + public void DisableSound() + { + previewLoader.DisableSound(); + } } \ No newline at end of file diff --git a/Assets/Scripts/JSBridge.cs b/Assets/Scripts/JSBridge.cs index 7746e6b..3bf5bc7 100644 --- a/Assets/Scripts/JSBridge.cs +++ b/Assets/Scripts/JSBridge.cs @@ -80,6 +80,12 @@ public void SetUrns(string value) => [UsedImplicitly] public void TakeScreenshot() => StartCoroutine(TakeScreenshotCoroutine()); + [UsedImplicitly] + public void EnableSound() => bootstrap.EnableSound(); + + [UsedImplicitly] + public void DisableSound() => bootstrap.DisableSound(); + private static async Awaitable TakeScreenshotCoroutine() { await Awaitable.EndOfFrameAsync(); diff --git a/Assets/Scripts/PreviewLoader.cs b/Assets/Scripts/PreviewLoader.cs index c73f399..78a19ef 100644 --- a/Assets/Scripts/PreviewLoader.cs +++ b/Assets/Scripts/PreviewLoader.cs @@ -305,6 +305,28 @@ public void PlayAnimation(bool play) } } + /// + /// Enables sound playback by setting audio source volume to 1. + /// + public void EnableSound() + { + if (audioSource != null) + { + audioSource.volume = 1f; + } + } + + /// + /// Disables sound playback by setting audio source volume to 0. + /// + public void DisableSound() + { + if (audioSource != null) + { + audioSource.volume = 0f; + } + } + private async Task LoadWearable(string category, WearableDefinition wd, AvatarColors avatarColors) { Debug.Log($"Loading wearable({category}): {wd.Pointer}");