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

How do I access isOn in a toggle?

Discussion in 'UGUI & TextMesh Pro' started by silentsam5, Sep 5, 2015.

  1. silentsam5

    silentsam5

    Joined:
    Sep 5, 2015
    Posts:
    3
    Question is in the title. I have unity 5.1.3f1 and i can't figure out how to access it in my scripts. doing something like

    rToggle.GetComponent<Toggle>().isOn;

    where rToggle is the game object comtaining the toggle UI, does not work. Toggle doesn't seem to be a component.
     
  2. silentsam5

    silentsam5

    Joined:
    Sep 5, 2015
    Posts:
    3
    Or, how do I check whether a toggle is selected
     
  3. silentsam5

    silentsam5

    Joined:
    Sep 5, 2015
    Posts:
    3
    Figured it out. Have to include UnityEngine.UI;