# AssertFormat

> Assert a condition and logs a formatted error message to the Unity console on failure.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## AssertFormat(bool, string, Object\[])

Assert a condition and logs a formatted error message to the Unity console on failure.

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void AssertFormat(bool condition, string format, params object[] args)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Condition you expect to be true.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): A composite format string.**** (\[Object\[]]\(https\://learn.microsoft.com/dotnet/api/system.object)): Format arguments.

### Remarks

Note that these methods work only if UNITY\_ASSERTIONS symbol is defined. This means that if you are building assemblies externally, you need to define this symbol otherwise the call becomes a no-op. (For more details see [System.Diagnostics.ConditionalAttribute](https://msdn.microsoft.com/en-us/library/system.diagnostics.conditionalattribute\(v=vs.110\).aspx) on the MSDN website.

## AssertFormat(bool, Object, string, Object\[])

Assert a condition and logs a formatted error message to the Unity console on failure.

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void AssertFormat(bool condition, Object context, string format, params object[] args)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Condition you expect to be true.**** (\[Object]\(/engine/6000.0/script-reference/unityengine/object)): Object to which the message applies.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): A composite format string.**** (\[Object\[]]\(https\://learn.microsoft.com/dotnet/api/system.object)): Format arguments.

### Remarks

Note that these methods work only if UNITY\_ASSERTIONS symbol is defined. This means that if you are building assemblies externally, you need to define this symbol otherwise the call becomes a no-op. (For more details see [System.Diagnostics.ConditionalAttribute](https://msdn.microsoft.com/en-us/library/system.diagnostics.conditionalattribute\(v=vs.110\).aspx) on the MSDN website.
