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; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| public static class ListExtensions | |
| { | |
| public static T PickRandom<T>(this IList<T> source) | |
| { | |
| if (source.Count == 0) | |
| return default(T); |
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
| /// <summary> | |
| /// Maps a value from some arbitrary range to the 0 to 1 range | |
| /// </summary> | |
| /// <param name="value">Value.</param> | |
| /// <param name="min">Lminimum value.</param> | |
| /// <param name="max">maximum value</param> | |
| public static float Map01(float value, float min, float max) | |
| { | |
| return (value - min) * 1f / (max - min); | |
| } |
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
| float height = 2*Camera.main.orthographicSize; | |
| float width = height*Camera.main.aspect; |
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
| # Ignore everything | |
| /* | |
| /*/ | |
| # Inverse ignore some stuff | |
| !/Assets/ | |
| !/ProjectSettings/ | |
| !.gitignore | |
| # OS Stuff |
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 static class ColliderExtensions { | |
| public static bool IsVisibleFrom(this Collider collider, Camera camera) | |
| { | |
| Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera); | |
| return GeometryUtility.TestPlanesAABB(planes, collider.bounds); | |
| } | |
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 UnityEditor; | |
| using UnityEngine; | |
| /// <summary> | |
| /// Right click on any script in your project that defines a ScriptableObject | |
| /// and create a ScriptableObject asset out of it! See here http://imgur.com/a/e7FDR#0 | |
| /// </summary> | |
| /// <author>Tim Aksu</author> | |
| /// <email>timur.s.aksu@gmail.com</email> | |
| public static class ScriptableObjectUtility |
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
| /* | |
| * When developing the UI system we came across a bunch of things we were not happy | |
| * with with regards to how certain events and calls could be sent in a loosely coupled | |
| * way. We had this requirement because with a UI you tend to implement widgets that receive | |
| * certain events, but you don't really want to have lots of glue code to manage them | |
| * and keep track of them. The eventing interfaces we developed helped with this. One of | |
| * the interesting things, is that they are not justfor the UI system! You can use this as | |
| * a type-safe, fast, and simple alternative to SendMessage (never use SendMessage!). | |
| * So how does it all work? |
NewerOlder