Beispiel #1
0
        //--------------------------------------------------------------------------------------------

        ///<summary>
        ///(Sphere Audio) Instiante a sound, play it and then destroy it
        ///<param name="aSound">The AudioData, with all setting already set, that need to be play</param>
        ///<param name="aPosition">The position where the sound will be instantiate</param>
        ///</summary>
        public void SoundEasy_Play(AudioData aSound, Vector3 aPosition)
        {
            if (!SFX_IsInit(true))
            {
                return;
            }
            if (aSound == null)
            {
                Debug.LogWarning(Debug_Warning("There's no sound to play"));
                return;
            }
            SFX_AudioSetup audio = Instantiate(new GameObject(), aPosition, Quaternion.identity).AddComponent <SFX_AudioSetup>();

            audio.SetAudioSource();
            audio.SetupAudio(aSound.GetClip(), aSound.GetVolume(), aSound.GetPitch(), aSound.GetSpatialBlend(), aSound.GetStereoPan());
            audio.PlayAudio(aSound.GetDelay());
        }
Beispiel #2
0
        ///<summary>
        /// The Sound system let's you play a sound from anywhere in the game. You only need to have an AudioData and a position you want the sound to be played and
        /// the manager will do the rest for you. You have 2 options, 1. EasySound, it will play a sound no matter what, instantiate one and destroy it just after it get done;
        /// 2. PerfSound, it will pick a sound already instantiate (from the start of the game), will modify him to be as you wish, play it and then put it back into a list.
        /// This option is more performant, but you need to set the number of sound you want from the start and if you exceed the amount (play to many sound at the same time)
        /// the Manager will first warn you, but will need to stop the first sound played (actually) to be able to play the new one.
        ///</summary>
        #region SOUND Functions

        private void InitSFXSystem()
        {
            GameObject perfParent = Instantiate(new GameObject(), transform);

            perfParent.name  = "PerfSounds[" + m_MaxAmountPerfSFX + "]";
            m_ListPerfSounds = perfParent.transform;

            SFX_AudioSetup audioInCreation = null;

            for (int i = 0; i < m_MaxAmountPerfSFX; i++)
            {
                audioInCreation      = Instantiate(new GameObject(), Vector3.zero, Quaternion.identity).AddComponent <SFX_AudioSetup>();
                audioInCreation.name = "PerfSound_" + i.ToString();
                audioInCreation.SetAudioSource();
                audioInCreation.transform.SetParent(m_ListPerfSounds);
                m_PerfSFXsAvailable.Add(audioInCreation);
            }

            m_SFXIsInit = true;
            Debug.Log(Debug_InitSucces("SFX System as been init"));
        }