예제 #1
0
    public bool AddSound(SoundEffect soundEffect, bool checkForDuplicate = false)
    {
        if (checkForDuplicate)
        {
            if (soundsDictionary.ContainsKey(soundEffect.id))
            {
                // The given sound effect has an id already registered in the sound manager.
                return(false);
            }
        }

        SoundEffectController sndController = gameObject.AddComponent <SoundEffectController>();

        soundEffect.ResetDefaults();
        sndController.InitComponent(soundEffect);

        soundsDictionary.Add(sndController.Id, sndController);

        numAllocatedAudioSources += soundEffect.maxAudioSources;

        // Succesfully created and registered the given sound effect.
        return(true);
    }