コード例 #1
0
        private IEnumerator _TextValue(TextMeshProUGUI text, string format, int from, int to, float time, float delay = 0, EffectOver effectOver = null)
        {
            float ElapsedTime = 0.0f;

            if (format == "")
            {
                format = "{0}";
            }

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (text == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                int currentVal = (int)Mathf.Lerp(from, to, (ElapsedTime / time));
                text.text = string.Format(format, currentVal.ToString());
                yield return(null);
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #2
0
        //Canvas group
        private IEnumerator _CanvasGroupAlpha(CanvasGroup cg, float visible, float time, float delay = 0, EffectOver effectOver = null)
        {
            float ElapsedTime = 0.0f;
            float startingVal = cg.alpha;

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (cg == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                cg.alpha     = Mathf.Lerp(startingVal, visible, (ElapsedTime / time));
                yield return(null);
            }

            cg.blocksRaycasts = (visible == 1) ? true:false;
            cg.interactable   = (visible == 1) ? true : false;

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #3
0
        private IEnumerator _Rotate(RectTransform rectTransform, Quaternion rotation, float time, float delay = 0, EffectOver effectOver = null, AnimationCurve curve = null)
        {
            float      ElapsedTime = 0.0f;
            Quaternion startRot    = rectTransform.rotation;

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (rectTransform == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                float value = (curve == null) ? (ElapsedTime / time) : curve.Evaluate((ElapsedTime / time));
                rectTransform.rotation = Quaternion.Lerp(startRot, rotation, value);
                yield return(null);
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #4
0
        private IEnumerator _Move(RectTransform rectTransform, Vector3 point, float time, float delay = 0, EffectOver effectOver = null, AnimationCurve curve = null)
        {
            float   ElapsedTime = 0.0f;
            Vector3 startPos    = rectTransform.anchoredPosition;

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (rectTransform == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                float value = (curve == null) ? (ElapsedTime / time) : curve.Evaluate((ElapsedTime / time));
                rectTransform.anchoredPosition = Vector3.Lerp(startPos, point, value);
                yield return(null);
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #5
0
        //Rect
        private IEnumerator _Scale(RectTransform _transform, Vector3 size, float time, float delay = 0, EffectOver effectOver = null, AnimationCurve curve = null)
        {
            float   ElapsedTime   = 0.0f;
            Vector3 startingScale = _transform.localScale;

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (_transform == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                float value = (curve == null) ? (ElapsedTime / time) : curve.Evaluate((ElapsedTime / time));
                _transform.localScale = Vector3.Lerp(startingScale, size, value);
                yield return(null);
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #6
0
        //Text
        private IEnumerator _TextFade(TextMeshProUGUI text, Color color, float time, float delay = 0, EffectOver effectOver = null, AnimationCurve curve = null)
        {
            float ElapsedTime   = 0.0f;
            Color startingColor = text.color;

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (text == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                float value = (curve == null) ? (ElapsedTime / time) : curve.Evaluate((ElapsedTime / time));
                text.color = Color.Lerp(startingColor, color, value);
                yield return(null);
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #7
0
        private IEnumerator _Fill(Image image, float value, float time, float delay = 0, EffectOver effectOver = null, AnimationCurve curve = null)
        {
            float ElapsedTime = 0.0f;
            float startingVal = image.fillAmount;

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (image == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                float timeValue = (curve == null) ? (ElapsedTime / time) : curve.Evaluate((ElapsedTime / time));
                image.fillAmount = Mathf.Lerp(startingVal, value, timeValue);
                yield return(null);
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #8
0
        private IEnumerator _TextAdder(TextMeshProUGUI text, char[] chars, float time, float delay = 0, EffectOver effectOver = null)
        {
            float TimeForEachChar = time / chars.Length;

            yield return(new WaitForSeconds(delay));

            foreach (char c in chars)
            {
                if (text == null)
                {
                    break;
                }

                text.text += c;
                yield return(new WaitForSeconds(TimeForEachChar));
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }
コード例 #9
0
        //Image
        private IEnumerator _Fade(Image image, Color color, float time, float delay = 0, EffectOver effectOver = null)
        {
            float ElapsedTime   = 0.0f;
            Color startingColor = image.color;

            yield return(new WaitForSeconds(delay));

            while (ElapsedTime < time)
            {
                if (image == null)
                {
                    break;
                }

                ElapsedTime += Time.deltaTime;
                image.color  = Color.Lerp(startingColor, color, (ElapsedTime / time));
                yield return(null);
            }

            if (effectOver != null)
            {
                effectOver.Invoke();
            }
        }