Beispiel #1
0
 private void OnDisable()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Beispiel #2
0
        private void Update()
        {
            if (Target.text != oldText)
            {
                if (Target.text.Contains("\t"))
                {
                    Target.text = Target.text.Replace("\t", string.Empty);


                    return;
                }


                if (TypeSound)
                {
                    if (NextSound < Time.time)
                    {
                        Audio2DListener.PlayUI(TypeSound, 1);
                        NextSound = Time.time + SoundLag;
                    }
                }

                UpdateText(Target.text);
            }
        }
Beispiel #3
0
        private void Call(bool value)
        {
            if (UseStaticValue)
            {
                if (value)
                {
                    if (ClickSound)
                    {
                        if (NextSound < Time.time)
                        {
                            Audio2DListener.PlayUI(ClickSound, 1);
                            NextSound = Time.time + SoundLag;
                        }
                    }

                    SetValue(StaticValueBinding.MemberName, StaticValue);
                }
            }
            else
            {
                if (ClickSound)
                {
                    if (NextSound < Time.time)
                    {
                        Audio2DListener.PlayUI(ClickSound, 1);
                        NextSound = Time.time + SoundLag;
                    }
                }

                SetValue(ValueBinding.MemberName, value);
            }
        }
Beispiel #4
0
        private IEnumerator PlayAsync(float delay)
        {
            if (Source)
            {
                Source.Stop();
                Source    = null;
                IsPlaying = false;
            }

            IsPlaying = true;

            if (delay > 0)
            {
                yield return(new WaitForSeconds(delay));
            }

            Source        = Audio2DListener.GetNext();
            Source.loop   = Loop;
            Source.pitch  = Pitch;
            Source.volume = Volume * AudioManager.GetVolume(Layer);
            Source.clip   = Clip;

            while (Source != null && Source.isPlaying)
            {
                yield return(1);
            }

            Source    = null;
            IsPlaying = false;
        }
Beispiel #5
0
        /// <summary>
        ///     Returns an instance of the Audio2dListener
        /// </summary>
        /// <returns></returns>
        public static Audio2DListener GetInstance()
        {
            if (Instance == null)
            {
                // create a new one
                var found = FindObjectOfType <AudioListener>();

                if (found == null)
                {
                    Debug.LogError("No AudioListener found !");
                    return(null);
                }

                Instance = found.gameObject.AddComponent <Audio2DListener>();
            }

            return(Instance);
        }
Beispiel #6
0
        private void HandleChange(float arg)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            if (SwipeSound != null)
            {
                if (NextSwipe < Time.time)
                {
                    Audio2DListener.PlayUI(SwipeSound, 1);
                    NextSwipe = Time.time + SoundLag;
                }
            }

            SetValue(ValueBinding.MemberName, arg);
        }
Beispiel #7
0
 private void OnEnable()
 {
     Instance = this;
 }