Debug.Log Extensions
Documentation (1.1.9)

◆ Guard() [2/2]

static bool Sisus.Debugging.Critical.Guard ( bool  condition,
int  channel,
Object  context = null 

Logs an error message to the Console if condition is not true and returns true if condition was false or true if it was not.

This can be useful for checking that the arguments passed to a function are valid and if not returning early with an error.

void CopyComponent(Component component, GameObject to)
if(Critical.Guard(component != null && to != null))
var copy = to.AddComponent(component.GetType());
var json = JsonUtility.ToJson(component);
JsonUtility.FromJsonOverwrite(json, copy);
conditionCondition you expect to be true.
channelThe channel to which the message belongs if logged.
contextObject to which the assertion applies.
true if condition was false; otherwise, false.