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. Dismiss Notice

Resolved [Editor] How to check if a Toggle property has been toggled?

Discussion in 'Scripting' started by Quasar47, Jan 13, 2022.

  1. Quasar47

    Quasar47

    Joined:
    Mar 24, 2017
    Posts:
    117
    Hello,
    I am using Editor.PropertyField() to draw a Toggle in my Inspector. I would like to know if it was possible to add a listener to that Toggle to activate a method when the user toggles the ui's value. I know it is easily done with the new UIElements and I'm thinking about converting my old code to the new system. But I would like to avoid it if possible. Is there a way to do it with the old system?

    Thank you for your help.
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Wrap it around a EditorGUI.BeginChangeCheck() and EndChangeCheck()?
     
  3. Quasar47

    Quasar47

    Joined:
    Mar 24, 2017
    Posts:
    117
    Thanks for the help, I completely forgot about BeginChangeCheck() .But i'm realizing the system I put in place is way too convoluted for it to work. I'll mark the thread as Solved since it still works with a simple Toggle.
     
    GroZZleR likes this.