This file contains 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; | |
//A component that allows you to subscribe to the Collision Events on a object (even if the main script does not lie on the object with the collider) | |
public class CollisionDetector : MonoBehaviour | |
{ | |
public delegate void Coll(Collider collider); | |
public event Coll CollisionEnter; | |
public event Coll CollisionStay; | |
public event Coll CollisionExit; |
This file contains 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
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour | |
{ | |
private static T instance; | |
public static T main | |
{ | |
get | |
{ | |
if (instance == null) | |
instance = FindObjectOfType<T>(); |
This file contains 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
public static class Extensions | |
{ | |
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component | |
{ | |
if(gameObject.TryGetComponent<T>(out T t)) | |
{ | |
return t; | |
} | |
else | |
{ |
This file contains 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; | |
[RequireComponent(typeof(BoxCollider2D), typeof(LineRenderer))] | |
public class LineCollider : MonoBehaviour | |
{ | |
private LineRenderer lineRenderer; | |
private BoxCollider2D boxCollider; | |
void Awake() | |
{ |