Skip to content

Instantly share code, notes, and snippets.

@RoeiRubach
Created October 14, 2021 13:23
Show Gist options
  • Select an option

  • Save RoeiRubach/b2a1df3b852fa1aac93b5f3442780027 to your computer and use it in GitHub Desktop.

Select an option

Save RoeiRubach/b2a1df3b852fa1aac93b5f3442780027 to your computer and use it in GitHub Desktop.
[Generic Caching Method]
private void ShouldCacheThing<TComponentType>(GameObject target, ref TComponentType field) where TComponentType : UnityEngine.Object //might need to be Component here
{
if (!field)
field = target.GetComponent<TComponentType>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment