Assert
Assert a condition and logs an error message to the Unity console on failure.
Read time 4 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
Assert(bool)
Assert a condition and logs an error message to the Unity console on failure.
[Conditional("UNITY_ASSERTIONS")]public static void Assert(bool condition)
Parameters
Condition you expect to be true.
Remarks
Message of a type of LogType.Assert is logged.
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 on the MSDN website.
Assert(bool, Object)
Assert a condition and logs an error message to the Unity console on failure.
[Conditional("UNITY_ASSERTIONS")]public static void Assert(bool condition, Object context)
Parameters
Remarks
Message of a type of LogType.Assert is logged.
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 on the MSDN website.
Assert(bool, Object)
Assert a condition and logs an error message to the Unity console on failure.
[Conditional("UNITY_ASSERTIONS")]public static void Assert(bool condition, object message)
Parameters
Remarks
Message of a type of LogType.Assert is logged.
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 on the MSDN website.
Assert(bool, string)
Assert a condition and logs an error message to the Unity console on failure.
[Conditional("UNITY_ASSERTIONS")]public static void Assert(bool condition, string message)
Parameters
Remarks
Message of a type of LogType.Assert is logged.
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 on the MSDN website.
Assert(bool, Object, Object)
Assert a condition and logs an error message to the Unity console on failure.
[Conditional("UNITY_ASSERTIONS")]public static void Assert(bool condition, object message, Object context)
Parameters
Remarks
Message of a type of LogType.Assert is logged.
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 on the MSDN website.
Assert(bool, string, Object)
Assert a condition and logs an error message to the Unity console on failure.
[Conditional("UNITY_ASSERTIONS")]public static void Assert(bool condition, string message, Object context)
Parameters
Remarks
Message of a type of LogType.Assert is logged.
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 on the MSDN website.
Assert(bool, string, Object[])
Assert a condition and logs an error message to the Unity console on failure.
[Conditional("UNITY_ASSERTIONS")]public static void Assert(bool condition, string format, params object[] args)
Parameters
Remarks
Message of a type of LogType.Assert is logged.
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 on the MSDN website.