コード例 #1
0
    public static void VolumeSize(float size)
    {
        AudioSource audioPlayer = StaticObject.GetInstance().GetComponent <AudioSource>();

        if (audioPlayer == null)
        {
            audioPlayer = StaticObject.GetInstance().gameObject.AddComponent <AudioSource>();
        }

        audioPlayer.volume = size;
    }
コード例 #2
0
    public void PlaySounds(string audioIndex)
    {
        AudioSource audioPlayer = StaticObject.GetInstance().GetComponent <AudioSource>();

        if (audioPlayer == null)
        {
            audioPlayer = StaticObject.GetInstance().gameObject.AddComponent <AudioSource>();
        }
        foreach (AudioClip audio in Sounds)
        {
            if (audio.name.Equals(audioIndex))
            {
                audioPlayer.clip   = audio;
                audioPlayer.volume = OptionValues.GetVolume();
                audioPlayer.Play();
            }
        }
    }