Ejemplo n.º 1
0
            protected override void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Attempts to scale the Graphic object to its' desired target.
                 */

                if (image != null)
                {
                    Color elementColor = image.color;
                    elementColor = Color.Lerp(elementColor, _finalColor, currentTransitionTime / totalTransitionTime);
                    if (currentTransitionTime >= totalTransitionTime)
                    {
                        elementColor = _finalColor;
                    }

                    image.color = elementColor;
                }
                else if (text != null)
                {
                    Color elementColor = text.color;
                    elementColor = Color.Lerp(elementColor, _finalColor, currentTransitionTime / totalTransitionTime);
                    if (currentTransitionTime >= totalTransitionTime)
                    {
                        elementColor = _finalColor;
                    }

                    text.color = elementColor;
                }
            }
Ejemplo n.º 2
0
            public void RunTransition(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Runs the transition on the Graphic object
                 */

                if (!_enableTransition)
                {
                    return;
                }

                if (eventStateElement == null)
                {
                    return;
                }

                Image image = eventStateElement.imageElement;
                Text  text  = eventStateElement.textElement;

                if (image == null && text == null)
                {
                    return;
                }

                RunTransition_Internal(eventStateElement, currentTransitionTime, totalTransitionTime, image, text);
            }
Ejemplo n.º 3
0
            protected override void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Attempts to scale the target to its' desired target.
                 */

                eventStateElement.cachedRectTransform.localScale = Vector3.Lerp(eventStateElement.cachedRectTransform.localScale, _scale, currentTransitionTime / totalTransitionTime);
                if (currentTransitionTime >= totalTransitionTime)
                {
                    eventStateElement.cachedRectTransform.localScale = _scale;
                }
            }
Ejemplo n.º 4
0
            protected override void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Attempts to rotate the Graphic object to its' desired target.
                 */

                eventStateElement.cachedRectTransform.eulerAngles = Vector3.Lerp(eventStateElement.cachedRectTransform.eulerAngles, _rotation, currentTransitionTime / totalTransitionTime);
                if (currentTransitionTime >= totalTransitionTime)
                {
                    eventStateElement.cachedRectTransform.eulerAngles = _rotation;
                }
            }
Ejemplo n.º 5
0
            protected override void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Lerps the color of the Text object
                 */

                float elementFontSize = text.fontSize;

                elementFontSize = Mathf.Lerp(elementFontSize, _finalFontSize, currentTransitionTime / totalTransitionTime);
                text.fontSize   = (int)Mathf.Ceil(elementFontSize);
                if (currentTransitionTime >= totalTransitionTime)
                {
                    elementFontSize = _finalFontSize;
                }
            }
Ejemplo n.º 6
0
            protected override void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Attempts to scale the Graphic object to its' desired target.
                 */

                if (image != null)
                {
                    image.material = _finalMaterial;
                }
                else if (text != null)
                {
                    text.material = _finalMaterial;
                }
            }
Ejemplo n.º 7
0
            protected override void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Attempts to set the Image's sprite to the destination sprite
                 */

                if (image == null)
                {
                    return;
                }

                image.sprite = _finalSprite;
                if (_useImageFill)
                {
                    // We need to manually set the sprite to "filled" after we change from a potentially null sprite
                    if (image.sprite != null)
                    {
                        image.type       = Image.Type.Filled;
                        image.fillMethod = _fillMethod;

                        if (_fillType == FillType.IncrementFill)
                        {
                            image.fillAmount = currentTransitionTime / totalTransitionTime;
                        }
                        else
                        {
                            image.fillAmount = 1 - (currentTransitionTime / totalTransitionTime);
                        }
                    }
                }

                if (currentTransitionTime >= totalTransitionTime)
                {
                    if (_fillType == FillType.IncrementFill)
                    {
                        image.fillAmount = 1;
                    }
                    else if (_fillType == FillType.DecrementFill)
                    {
                        image.fillAmount = 0;
                    }
                }
            }
Ejemplo n.º 8
0
            protected override void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
            {
                /*
                 *    For internal use only
                 *    ---------------------
                 *    Changes the actual Text of a text element
                 */

                if (text == null)
                {
                    return;
                }

                string endText = text.text;

                if (!_writeoutOverDuration || currentTransitionTime >= totalTransitionTime)
                {
                    endText = _finalString;
                }
                else
                {
                    int   stringLength        = _finalString.Length;
                    float roughStringPosition = stringLength * (currentTransitionTime / totalTransitionTime);
                    int   finalStringLength   = Mathf.CeilToInt(roughStringPosition);
                    if (finalStringLength > stringLength)
                    {
                        finalStringLength = stringLength;
                    }

                    if (finalStringLength < 1)
                    {
                        finalStringLength = 1;
                    }

                    endText = _finalString.Substring(0, finalStringLength - 1);
                }

                text.text = endText;
            }
Ejemplo n.º 9
0
 protected virtual void RunTransition_Internal(UIGraphicEventState eventStateElement, float currentTransitionTime, float totalTransitionTime, Image image, Text text)
 {
     throw new System.NotImplementedException();
 }