Example #1
0
    protected void Awake()
    {
        base.Awake();

        audioSource = GetComponent <AudioSource>();

        // Get sound effects/music from SoundDatabase
        SoundDatabase soundDatabase = Resources.Load <SoundDatabase>(databasePath);

        if (soundDatabase == null)
        {
            Debug.LogError("Cound not find sound databsae at " + databasePath);
        }
        else
        {
            // Combine each collection of sound effects
            soundEffects    = soundDatabase.GetSoundEffects();
            backgroundMusic = soundDatabase.GetMusic();

            // Set music to selected track
            SetMusic(music);
        }
    }