Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ask] Mixer on outside JSAM Audio Source #37

Open
StinkySteak opened this issue May 27, 2024 · 2 comments
Open

[Ask] Mixer on outside JSAM Audio Source #37

StinkySteak opened this issue May 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@StinkySteak
Copy link

JSAM Version: 3.0.0 preview 6
Unity: 2021.3.21f1

How do we make sure the mixer works for a audio source not managed by JSAM?

@StinkySteak
Copy link
Author

It seems the mixer doesn't really used or functioned?

For my case I currently call Start/Awake/OnEnable, then call my source.volume = AudioManager.SoundVolume

@jackyyang09
Copy link
Owner

There is currently no easy way to make JSAM's Audio Manager manage your own Audio Source. I'll be working on adding a solution for this in the next update.

I apologize for the long wait, but if if you still need help on this issue, what you can do is create a script that hooks onto the AudioManager's volume change events and changes an AudioSource's volume level automatically. Something like the below.

public class ManagedSource : MonoBehaviour
{
    public float relativeVolume;
    public AudioSource source;

    private void Start()
    {
        AudioManager.OnSoundVolumeChanged += UpdateVolume;
    }

    private void OnDestroy()
    {
        AudioManager.OnSoundVolumeChanged -= UpdateVolume;
    }

    void UpdateVolume(float v)
    {
        source.volume = relativeVolume * v * AudioManager.MasterVolume;
    }
}

@jackyyang09 jackyyang09 added the enhancement New feature or request label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants