// Color tweens
        public Tweener DOFade(int charIndex, float endValue, float duration)
        {
            NotifyActiveColorTween();
            ProxyColor proxy = GetProxyColor(charIndex);

            return(proxy.AddTween(proxy.DOFade(endValue, duration)));
        }
        public Tweener DOGradient(int charIndex, VertexGradient endValue, float duration)
        {
            NotifyActiveColorTween();
            ProxyColor proxy = GetProxyColor(charIndex);

            return(proxy.AddTween(proxy.DOColorGradient(endValue, duration)));
        }
Example #3
0
        private void UpdateCharColors()
        {
            // If no color tweens have been created then the list of proxies will not exist
            if (proxyColorList == null)
            {
                return;
            }

            for (var i = proxyColorList.Count - 1; i >= 0; i--)
            {
                ProxyColor proxy = proxyColorList[i];
                if (proxy.CharIndex >= characterCount)
                {
                    continue;
                }

                TMP_CharacterInfo charInfo = Text.textInfo.characterInfo[proxy.CharIndex];
                if (!charInfo.isVisible || !proxy.IsModified)
                {
                    continue;
                }

                int materialIndex = charInfo.materialReferenceIndex;
                int vertexIndex   = charInfo.vertexIndex;

                Color32[] destinationColors = Text.textInfo.meshInfo[materialIndex].colors32;
                destinationColors[vertexIndex + 1] = proxy.ColorGradient.topLeft;
                destinationColors[vertexIndex + 2] = proxy.ColorGradient.topRight;
                destinationColors[vertexIndex + 0] = proxy.ColorGradient.bottomLeft;
                destinationColors[vertexIndex + 3] = proxy.ColorGradient.bottomRight;
            }
        }
Example #4
0
        /// <summary>
        /// Cleans up tweens that are not active.
        /// </summary>
        public void DisposeInactiveTweens()
        {
            transformTweensActive = false;
            if (proxyTransformList != null)
            {
                for (var i = proxyTransformList.Count - 1; i >= 0; i--)
                {
                    ProxyTransform proxy = proxyTransformList[i];
                    proxy.DisposeFinishedTweens();
                    if (proxy.Tweens.Count > 0)
                    {
                        transformTweensActive = true;
                    }
                }
            }

            colorTweensActive = false;
            if (proxyColorList != null)
            {
                for (var i = proxyColorList.Count - 1; i >= 0; i--)
                {
                    ProxyColor proxy = proxyColorList[i];
                    proxy.DisposeFinishedTweens();
                    if (proxy.Tweens.Count > 0)
                    {
                        colorTweensActive = true;
                    }
                }
            }
        }
Example #5
0
        /// <summary>Completes all character tweens on the text mesh</summary>
        /// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
        /// otherwise they will be ignored</param>
        public void CompleteAll(bool withCallbacks = false)
        {
            if (proxyTransformList != null)
            {
                for (var i = 0; i < proxyTransformList.Count; i++)
                {
                    ProxyTransform proxy = proxyTransformList[i];
                    for (int j = 0; j < proxy.Tweens.Count; j++)
                    {
                        proxy.Tweens[j].Complete(withCallbacks);
                    }
                    proxy.Tweens.Clear();
                }
            }

            if (proxyColorList != null)
            {
                for (var i = 0; i < proxyColorList.Count; i++)
                {
                    ProxyColor proxy = proxyColorList[i];
                    for (int j = 0; j < proxy.Tweens.Count; j++)
                    {
                        proxy.Tweens[j].Complete(withCallbacks);
                    }
                    proxy.Tweens.Clear();
                }
            }
        }
Example #6
0
        // Will create proxy if does not exist
        private ProxyColor GetProxyColor(int charIndex)
        {
            if (proxyColorDict == null)
            {
                proxyColorDict = new Dictionary <int, ProxyColor>(CharacterCount);
                proxyColorList = new List <ProxyColor>(CharacterCount);
            }

            ProxyColor proxy;

            if (!proxyColorDict.TryGetValue(charIndex, out proxy))
            {
                proxy = new ProxyColor(Text.color, Text.colorGradient, Text.enableVertexGradient, charIndex);
                proxyColorDict.Add(charIndex, proxy);
                proxyColorList.Add(proxy);
                return(proxy);
            }

            return(proxy);
        }
        public float GetAlpha(int charIndex)
        {
            ProxyColor proxyColor = TryGetProxyColor(charIndex);

            return(proxyColor != null ? proxyColor.Alpha : Text.alpha);
        }
        public VertexGradient GetColorGradient(int charIndex)
        {
            ProxyColor proxyColor = TryGetProxyColor(charIndex);

            return(proxyColor != null ? proxyColor.ColorGradient : Text.colorGradient);
        }
        public Color GetColor(int charIndex)
        {
            ProxyColor proxyColor = TryGetProxyColor(charIndex);

            return(proxyColor != null ? proxyColor.Color : Text.color);
        }