Skip to content

Instantly share code, notes, and snippets.

@ahokinson
Created February 13, 2017 23:07
Show Gist options
  • Save ahokinson/d98d0e56ec9b18b9383f62e17ad13fea to your computer and use it in GitHub Desktop.
Save ahokinson/d98d0e56ec9b18b9383f62e17ad13fea to your computer and use it in GitHub Desktop.
using UnityEngine;
namespace Gubbins.Assertions
{
public static class Assert
{
public static void AssignIfNull<T>(ref T value) where T : Object
{
if (value != null) return;
value = Object.FindObjectOfType<T>();
Debug.LogAssertion("Assertion failed. " + (value != null ? value.name : "Nothing") +
" was found for missing " + typeof(T));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment