Search Unity

Newbie question about influencing the UI from script

Discussion in 'UGUI & TextMesh Pro' started by Xiph, Aug 25, 2014.

  1. Xiph

    Xiph

    Joined:
    Jun 20, 2013
    Posts:
    2
    Hi,

    I hope you can all tolerate my low level of understanding.

    I understand how UI elements can be made to call functions within scripts. What I can't get my head around ishow to do the reverse. For example, if I had a variable somewhere, and I wanted a toggle control to display the status of that variable, how on earth would I do it?

    If anyone can show me, in UnityScript, I'd be most grateful!
     
  2. Xiph

    Xiph

    Joined:
    Jun 20, 2013
    Posts:
    2
    I hope I'm allowed to bring this question back to the front page from page three!
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    You need to write a script and place it on the same GO as the toggle control. This script would reference both the toggle and the script which contains the variable you want to have displayed. You would then need to have a Update function which would constantly look at the variable and assign it to the toggle.