Search Unity

InputField current color

Discussion in 'UGUI & TextMesh Pro' started by Edgaras-Randis, Dec 9, 2014.

  1. Edgaras-Randis

    Edgaras-Randis

    Joined:
    Jul 8, 2014
    Posts:
    20
    Input field has multiple color values over different states. How can i get current color value? Because I don't see anything related to that atm.
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    you have to look at the targetGraphic.color as thats where its written to when the transition happens.
     
  3. Edgaras-Randis

    Edgaras-Randis

    Joined:
    Jul 8, 2014
    Posts:
    20
    Tried that one and it returns the image component color without current transition color.
     
  4. Edgaras-Randis

    Edgaras-Randis

    Joined:
    Jul 8, 2014
    Posts:
    20

    Had to look at repo for this one, and it seems it writes to the canvasRenderer.SetColor

    UnityEngine.UI / UI / Core / Graphic.cs

    Code (CSharp):
    1. private void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB)
    2. {
    3. ....
    4.             colorTween.AddOnChangedCallback(canvasRenderer.SetColor);
    5. ....
    6. }
    In other words for someone who will look someday for this: InputField.targetGraphic.canvasRenderer.GetColor().
     
    Last edited: Dec 9, 2014
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    :( sorry my bad i took it as a different function call but you are correct.