コード例 #1
0
    private void PlayMusicIfExists(string audioName)
    {
        AudioFile audioFile = MusicFiles.Find(audio => audio.name.Equals(audioName));

        if (audioFile == null)
        {
            return;
        }

        if (CurrentMusic.GetAudioSource() != null)
        {
            CurrentMusic.GetAudioSource().Stop();
        }
        CurrentMusic = audioFile;
        CurrentMusic.GetAudioSource().Play();
    }
コード例 #2
0
    private void PlaySFXIfExists(string audioName)
    {
        AudioFile audioFile = SFXFiles.Find(audio => audio.name.Equals(audioName));

        if (audioFile == null)
        {
            return;
        }

        audioFile.GetAudioSource().Play();
    }