internal static void CheckOnGUI() { if (GUIUtility.Internal_GetGUIDepth() <= 0) { throw new ArgumentException("You can only call GUI functions from inside OnGUI."); } }