예제 #1
0
        /**
         * Kinda deprecated see -> ShowNotification
         */
        public async UniTaskVoid ShowToast(string text, int duration = 2)
        {
            var originalColor = toast.color;

            toast.text    = text;
            toast.enabled = true;

            //Fade in
            toast.FadeInAndOut(true, 0.5f).Forget();
            toastBackground.FadeInAndOut(true, 0.5f).Forget();

            //Wait for the duration
            float counter = 0;

            while (counter < duration)
            {
                counter += Time.deltaTime;
                await UniTask.Yield();
            }

            //Fade out
            toast.FadeInAndOut(false, 0.5f).Forget();
            toastBackground.FadeInAndOut(false, 0.5f).Forget();

            toast.enabled = false;
            toast.color   = originalColor;
        }