Home>

I am making a game title screen in Unity. There are two scenes, Title and Menu. In Title, Title BGM is played. (Currently, AUdio Sourse is put in the Main Camera and DC is in the state.) I want to make a click sound when clicked on the title, stop TitleBGM, move to the Menu scene with FadeManager, and play the Menu BGM.

FadeManager
https://materializer.co/lab/blog/139

Corresponding source code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MusicManager: MonoBehaviour
{
    public AudioClip BGM_title;
    public AudioClip SOUND_Click;

    // Start is called before the first frame update
    void Start ()
    {
    }
    // Update is called once per frame
    void Update ()
    {
    }
}
What I tried

I tried to use different sounds with AudioClip, but it didn't work.

Supplementary information (FW/tool version, etc.)

Unity is 3.6f1 in 2019

  • Answer # 1

    public class MusicManager: MonoBehaviour
    {
        public AudioClip title BGM;
        public AudioClip Click;
       // public AudioClip menuBGM;
        AudioSource audiosource;
        // Start is called before the first frame update
        void Start ()
        {
            audiosource = GetComponent  ();
            audiosource.PlayOneShot (titleBGM);
        }
        // Update is called once per frame
        void Update ()
        {
            if (Input.GetMouseButtonDown (0))
            {
                FadeManager.Instance.LoadScene ("Menu", 0.3f);
                audiosource.PlayOneShot (Click);
            }
        }
    } ** This solved it **