Debug.Log Extensions
Documentation (1.1.9)

◆ Ensure() [4/5]

static bool Debug.Ensure ( bool  condition,
string  message,
Object  context = null 
)
static

If condition is false logs to the Console an error message and returns false.

If condition is true returns true without logging anything.

An error is only logged the first time during a session that the condition evaluates to false to avoid flooding the log file.

In release builds an error will only be logged if the UNITY_ASSERTIONS symbol is defined.

private float Divide(float dividend, float divisor)
{
return Debug.Ensure(divisor != 0f) ? dividend / divisor : 0f;
}
static bool Ensure(bool condition, Object context=null)
If condition is false logs to the Console an error message and returns false.
Definition: Debug.cs:3838
Extended version of the built-in Debug class with additional methods to ease debugging while developi...
Definition: Debug.cs:34
Parameters
conditionCondition you expect to be true.
messageMessage to display if condition is false.
contextObject to which the assertion applies.
Returns
true if condition was true; otherwise, false.