Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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 Unity Technologies

    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 Unity Technologies

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