# ExitGUIException

> An exception that will prevent all subsequent immediate mode GUI functions from evaluating for the remainder of the GUI loop.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.IMGUIModule
* **Inherits from:** [Exception](https://learn.microsoft.com/dotnet/api/system.exception)
* **Implements:** [ISerializable](https://learn.microsoft.com/dotnet/api/system.runtime.serialization.iserializable)

```csharp
public sealed class ExitGUIException : Exception, ISerializable
```

## Remarks

If you have exception handling in your [GUI](/engine/6000.6/script-reference/unityengine/gui.md) code, it should not catch this exception type, as Unity's immediate mode GUI system relies on this exception to exit the current [GUI](/engine/6000.6/script-reference/unityengine/gui.md) loop properly in some cases.

If you need to exit the immediate mode GUI loop in your own code, you should call [GUIUtility.ExitGUI](/engine/6000.6/script-reference/unityengine/guiutility/exitgui.md) rather than throwing this exception directly.

## Inheritance

**Inherited Members:**

* [Exception.GetBaseException()](https://learn.microsoft.com/dotnet/api/system.exception.getbaseexception)
* [Exception.GetObjectData(SerializationInfo, StreamingContext)](https://learn.microsoft.com/dotnet/api/system.exception.getobjectdata)
* [Exception.ToString()](https://learn.microsoft.com/dotnet/api/system.exception.tostring)
* [Exception.GetType()](https://learn.microsoft.com/dotnet/api/system.exception.gettype)
* [Exception.TargetSite()](https://learn.microsoft.com/dotnet/api/system.exception.targetsite)
* [Exception.Message()](https://learn.microsoft.com/dotnet/api/system.exception.message)
* [Exception.Data()](https://learn.microsoft.com/dotnet/api/system.exception.data)
* [Exception.InnerException()](https://learn.microsoft.com/dotnet/api/system.exception.innerexception)
* [Exception.HelpLink()](https://learn.microsoft.com/dotnet/api/system.exception.helplink)
* [Exception.Source()](https://learn.microsoft.com/dotnet/api/system.exception.source)
* [Exception.HResult()](https://learn.microsoft.com/dotnet/api/system.exception.hresult)
* [Exception.StackTrace()](https://learn.microsoft.com/dotnet/api/system.exception.stacktrace)
