Skip to content

Instantly share code, notes, and snippets.

@SeppahBaws
Created January 13, 2019 13:28
Show Gist options
  • Select an option

  • Save SeppahBaws/bca394e159f71bdfd5335613f50b1bc4 to your computer and use it in GitHub Desktop.

Select an option

Save SeppahBaws/bca394e159f71bdfd5335613f50b1bc4 to your computer and use it in GitHub Desktop.

Revisions

  1. SeppahBaws created this gist Jan 13, 2019.
    20 changes: 20 additions & 0 deletions Utils.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    public static class Utils
    {
    public static bool NullCheck(this object obj, string msg = "")
    {
    if (obj == null)
    {
    if (msg != "")
    Debug.LogError(msg);
    return true;
    }
    return false;
    }
    }


    // --- Usage: ---
    Transform someObj = transform.Find("SomeChild");
    if (someObj.NullCheck("someObj not found!")) return;
    // do stuff with someObj
    // ...