daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Feb 17th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class UsingDelegates : MonoBehaviour
  2. {
  3.     private List<Unicorn> unicorns = new List<Unicorn>();
  4.     Vector3 playerPosition;
  5.  
  6.     static Func<Unicorn, Vector3, bool> isCloseTo = (Unicorn unicorn, Vector3 position) => (position - unicorn.transform.position).magnitude > 5f;
  7.  
  8.     void Update()
  9.     {
  10.         unicorns.ForEach(@if: isCloseTo, then: Unicorn.GiveHug, arg1: playerPosition);
  11.     }
  12. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top