Search Unity

Problem with animating GUI text object inside the Canvas

Discussion in 'Animation' started by Jp Lammi, Jan 20, 2015.

  1. Jp Lammi

    Jp Lammi

    Joined:
    Jan 20, 2015
    Posts:
    2
    Hello,

    I am just learning unity and I have come across interesting problem.

    I am trying to animate simple text fading animation for a GUI text object inside the Canvas. I am creating the animation through the UI.Text component which by name of TextFade.anim and it also creates the Text.controller for it. The animation is simple, changing the text color from 0, 0, 0, 1 to 1, 1, 1, 1 and back to 0, 0, 0, 1.

    The problem occurs when I close the unity and start the project again, it somehow loses the connection to the Text controller. After reloading the project, it shows following information in the animation window:

    Text: Mono Behavioud.Color (text in yellow color)

    And I can't change the curve values for the color anymore as they all were reset to 0, 0, 0, 0.

    What I am doing wrong and is there a way to fix this?
     
  2. Jp Lammi

    Jp Lammi

    Joined:
    Jan 20, 2015
    Posts:
    2
    I found a work around for this:

    public Color textColor;

    void Start () {
    textColor = GetComponent<Text>().color;
    }

    void Update () {
    GetComponent<Text>().color = textColor;
    }

    And then used the public variable in the animation tab to animate the color from black to white and back. Not sure but it seems that there might be a bug in the UI.Text-object's Text-component.