音乐和音效

时间:2018-08-18 06:06:55

标签: c# unity3d

如何分离音乐背景和声音效果的开和关(我的意思是如何使分离静音)

AudioManager

public Sound[] sounds;

public static AudioManager instance;

void Awake()
{
    if (instance == null)
        instance = this;
    else
    {
        Destroy(gameObject);
        return;
    }

    DontDestroyOnLoad(gameObject);

    foreach (Sound s in sounds)
    {
        s.source = gameObject.AddComponent<AudioSource>();
        s.source.clip = s.clip;

        s.source.volume = s.volume;
        s.source.loop = s.loop;
        s.source.mute = s.mute;
    }
}

Sound.cs

public string name;
public AudioClip clip;

[Range(0f, 1f)]
public float volume;

public bool loop;
public bool mute;

[HideInInspector]
public AudioSource source;

This is my Music and Sound Effects

0 个答案:

没有答案