Well, the bug is in the code that does this funky stuff, so it’s obviously not a Unity bug. Not that it never happened to me - but when you get more of an understanding of how UnityGUI works, it happens less frequently
I guess one key to understand this is that OnGUI() is called a couple of times, with different purposes. You can check why it is called via Event.current. Not perfectly sure, but I think the first time it is called in:
So … anything that changes the layout of your GUI must have been done before that, and you should not change the layout afterwards (unless, maybe through UnityGUI-related user actions). If you look at the documentation of EventType, you’ll find a few other noteworthy events like Repaint.
Ok, perhaps ‘bug’ isn’t the right word for it… because OnGUI is working the way it was intended. Also I can’t seem to find it AngryAnt, where in the documentation is it stated ‘dont do this’?
I still feel this issue needs addressing… It might be as simple as the fact that the Error message is completely unhelpful in terms of working out what’s going on…
It needs to explicitly say “You’ve changed a variable in OnGUI without the user’s input” or something… not just output a mystical message about ‘groups’.
You don’t know how grateful I am to you sir, Thanks, Thanks, Thanks. That solved the problem Like a charm, alghough my soloution was to check do this on top of the method onGui:
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (Event.current.type != EventType.Repaint)
return;
//
///
}