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

EditorGUI.Toggle not toggling

Discussion in 'Scripting' started by jefferytitan, Dec 2, 2014.

  1. jefferytitan

    jefferytitan

    Joined:
    Jul 19, 2012
    Posts:
    88
    Hi all,

    I have a problem with Unity custom inspector toggles. I'm using one in a PropertyDrawer, and I can't toggle it by clicking on the checkbox, only by clicking the toggle label and pressing space.

    I'm at a bit of a loss how to diagnose/fix it. Any suggestions would be greatly appreciated.

    Thanks,
    JT
     
  2. RSG

    RSG

    Joined:
    Feb 20, 2013
    Posts:
    93
    I recommend posting your code to help narrow down the issue.
     
  3. jefferytitan

    jefferytitan

    Joined:
    Jul 19, 2012
    Posts:
    88
    I have a rather complex inspector, I'll get a more minimal example that demonstrates the problem later.
     
  4. yoyo

    yoyo

    Joined:
    Apr 16, 2010
    Posts:
    112
    I had the same problem. It turned out the rectangle I was passing to EditorGUI.Toggle was incorrectly calculated -- it was close enough to get the toggle label and checkbox in the right place, but not for mouse interaction on the checkbox. I had been calculating the rectangle once for a series of checkboxes and then just adding an offset to yMin for each successive checkbox. When I calculate the correct rectangle explicitly for each checkbox it works perfectly.
     
    Xtro and kadd11 like this.