- Home /
Why isn't there an overload method for EditorGUILayout.Toggle to toggleOnLabelClick?
EditorGUILayout.Foldout has a convenient overload method named toggleonlabelclick to prevent the bool from switching if you click outside of the arrow.
https://docs.unity3d.com/ScriptReference/EditorGUILayout.Foldout.html
Why doesn't the same exist for EditorGUILayout.Toggle? https://docs.unity3d.com/ScriptReference/EditorGUILayout.Toggle.html
And is it possible to create an overload method for it?
Answer by Adam-Mechtley · Mar 12, 2017 at 09:08 PM
Why doesn't the same exist for EditorGUILayout.Toggle?
In general the answer is because the IMGUI APIs are completely out of control with overrides. You should be able to trivially implement a control like this though by just using the Foldout API for your toggle with the override you noted, but passing in EditorStyles.toggle for the style.
This worked! Thank you so much. I need to familiarize myself with those EditorStyles. Just in case someone else stumbles across this, here's the final answer:
foldoutBool = EditorGUILayout.Foldout(foldoutBool, "", false, EditorStyles.toggle);
Your answer
Follow this Question
Related Questions
Drag editing on a EditorGUILayout.FloatField 1 Answer
Unity editor extension - create drag and drop (similar to Buildbox) 1 Answer
Custom inspector difficulties creating a Box / Group like widget 1 Answer
Custom Inspector for a List ? 2 Answers
Finding a GameObject in an editor script based on position 2 Answers