Example #1
0
        /// <summary>
        /// Retrurns true if the soundName was found or was added to the database
        /// </summary>
        /// <param name="soundName"></param>
        /// <returns></returns>
        private bool AddSoundToDatabase(string soundName)
        {
            InitSoundsDatabase();
            if (soundsDatabase.ContainsKey(soundName))
            {
                return(true);
            }
            UISound soundItem = DUI.GetUISound(soundName);

            if (soundItem == null)
            {
                Debug.Log("NULL UISound"); return(false);
            }                                                                   //the UISound was not found in the Resources folder -> thus it could not be added
            soundsDatabase.Add(soundName, soundItem);
            return(true);
        }
Example #2
0
        public static bool PreviewSound(string soundName)
        {
            if (string.IsNullOrEmpty(soundName.Trim()) || soundName.Equals(DUI.DEFAULT_SOUND_NAME))
            {
                return(false);
            }
#if dUI_MasterAudio
            DTGUIHelper.PreviewSoundGroup(soundName);
            return(true);
#else
            if (DUI.UISoundsDatabase == null)
            {
                DUI.RefreshUISoundsDatabase();
            }
            if (!DUI.UISoundNameExists(soundName))
            {
                return(false);
            }

            AudioClip audioClip = DUI.GetUISound(soundName).audioClip;
            if (audioClip != null) //there is an AudioClip reference -> play it
            {
                QUtils.PlayAudioClip(audioClip);
                return(true);
            }


            audioClip = Resources.Load(DUI.GetUISound(soundName).soundName) as AudioClip;
            if (audioClip != null) //a sound file with the soundName was found in Resources -> play it
            {
                QUtils.PlayAudioClip(audioClip);
                return(true);
            }

            return(false);
#endif
        }