"You can only call GUI functions from inside OnGui"

I have a small project with some GUI components (A basic menu with some text, two panels and some buttons).

From a time, I’ve been getting this error when opening the project for the first time (And when I run the game and then go back to the editor, the error dissapears):

ArgumentException: You can only call GUI functions from inside OnGUI.
UnityEngine.GUIUtility.CheckOnGUI () (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:293)
UnityEngine.GUI.get_skin () (at C:/buildslave/unity/build/Modules/IMGUI/GUI.cs:42)
GitHub.Unity.Styles.get_Label () (at C:/projects/unity/src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs:210)
GitHub.Unity.Utility.get_IsDarkTheme () (at C:/projects/unity/src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Utility.cs:18)
GitHub.Unity.Styles.get_ActiveBranchIcon () (at C:/projects/unity/src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs:823)
GitHub.Unity.BranchesView.OnEnable () (at C:/projects/unity/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs:76)
GitHub.Unity.Window.OnEnable () (at C:/projects/unity/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/Window.cs:131)
UnityEditorInternal.InternalEditorUtility:LoadSerializedFileAndForget(String)
UnityEditor.WindowLayout:LoadDefaultWindowPreferences() (at C:/buildslave/unity/build/Editor/Mono/GUI/WindowLayout.cs:40)

(Notice that the paths listed in this message does not exist on my machine, unless they are created when running the game from the editor)

The GUI components I have communicate through a simple event system where components are enabled/disabled. The clickListeners for the buttons are assigned via editor, and, as long as I know, there is not a single call to a “GuI function”, as the error writes, in the whole project. The inly thing I can think of as “GUI function” could be a call to a text component to change it (from a score board), but I think I’m confusing here what a “GUI function” is.

So, Ithis is a more or less broad question, because I don’t really know where to even look: What should I be looking for to clear this error? Is a bug of some Unity component? Does anyone knows why this error could be being thrown?

It looks like an issue with the GitHub extension you are using. Its calling get_skin from inside of OnEnable.

Huh, somehow I thought the extension would update on its own. I’ve re-imported it and now the error has dissapeared. Thanks!

2 Likes