Created
July 1, 2017 20:25
-
-
Save unity3dcollege/7dfab83b9c092046518987357831d4e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var coinsByDistance = allCoins.OrderBy(Vector3.Distance(transform.position, t.transform.position); | |
yield return new WaitForSeconds(1f); // Vector3.Distance hasn't called once, everything's still deffered | |
if (Input.GetKeyDown(KeyCode.A)) | |
{ | |
foreach (var coin in coinsByDistance) // This iteration makes the LINQ statement execute. | |
{ | |
coin.DoSomething(); | |
} | |
} | |
else | |
{ | |
Debug.Log("Player didn't press 'A'... so nothing's causing the LINQ statement to be executed"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment