Guest User

Untitled

a guest
Feb 17th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment