Debug.Log Extensions
Documentation (1.1.9)

◆ Assert() [11/11]

static void Debug.Assert ( [NotNull] Expression< Func< object >>  classMember,
[CanBeNull] Object  context = null 
)
static

Logs an error message to the Console if classMember value is not true.

Class member can be of type bool or any type that implements IConvertible.

Class member can also be of type Object or any other class type object in which case an error will be logged if its value is null.

Note that this method only works if UNITY_ASSERTIONS symbol is defined, like for example in development builds.

public int GetValue()
{
bool valueFound = dictionary.TryGetValue(out int value);
Debug.Assert(()=>valueFound);
return value;
}
static void Assert(bool condition, int channel, Object context=null)
Logs an error message to the Console if condition is not true.
Definition: Debug.cs:3381
Extended version of the built-in Debug class with additional methods to ease debugging while developi...
Definition: Debug.cs:34
Parameters
classMemberExpression pointing to the class member with the expected value.
contextObject to which the assertion applies.