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
| using System.IO; | |
| using System.Linq; | |
| using UnityEditor; | |
| using UnityEngine; | |
| public class CleanEmptyFoldersEditorExtension : EditorWindow | |
| { | |
| private static string deletedFolders; | |
| [MenuItem("Tools/Clean Empty Folders")] |
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
| using TMPro; | |
| using UnityEngine; | |
| using UnityEngine.UI; | |
| public class SliderValueText : MonoBehaviour | |
| { | |
| [SerializeField] | |
| [Tooltip("The text shown will be formatted using this string. {0} is replaced with the actual value")] | |
| private string formatText = "{0}°"; |
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
| using UnityEngine; | |
| public class Cannon : MonoBehaviour | |
| { | |
| [SerializeField] | |
| private Rigidbody cannonballInstance; | |
| [SerializeField] | |
| [Range(10f, 80f)] | |
| private float angle = 45f; |
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
| private GameObject GetNearestGameObject(List<GameObject> gameObjectsToConsider) | |
| { | |
| float smallestDistance = Mathf.Infinity; | |
| GameObject nearestGameObject; | |
| foreach(var go in gameObjectsToConsider) | |
| { | |
| var distance = Vector3.Distance(transform.position, go.transform.position); | |
| if (distance < smallestDistance) | |
| { |
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 nearest = gameObjectsToConsider | |
| .OrderBy(t=> Vector3.Distance(transform.position, t.transform.position) | |
| .FirstOrDefault(); |
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 enemiesToTarget = allEnemies.OrderBy(t => t.Health).Take(numberICanTarget); |
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 dogsInOrder = allDogs.OrderBy(t=> t.Color) | |
| .ThenBy(t=> t.Size); |
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); |
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(); | |
| } | |
| } |
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
| using System.Linq; |