-
-
Save ryanmeier/efa700d67f51e9929696 to your computer and use it in GitHub Desktop.
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; | |
using System.Collections; | |
public class InvisibleTrigger : MonoBehaviour | |
{ | |
public Color color = Color.white; | |
private BoxCollider2D boxCollider = null; | |
private BoxCollider2D BoxCollider | |
{ | |
get | |
{ | |
if(boxCollider == null) | |
{ | |
boxCollider = GetComponent<BoxCollider2D>(); | |
} | |
return boxCollider; | |
} | |
} | |
private CircleCollider2D sphereCollider = null; | |
private CircleCollider2D SphereCollider | |
{ | |
get | |
{ | |
if(sphereCollider == null) | |
{ | |
sphereCollider = GetComponent<CircleCollider2D>(); | |
} | |
return sphereCollider; | |
} | |
} | |
void OnDrawGizmos() | |
{ | |
Color oldColor = Gizmos.color; | |
Gizmos.color = color; | |
if(BoxCollider != null) | |
{ | |
Gizmos.DrawWireCube(transform.position, new Vector3(BoxCollider.size.x, BoxCollider.size.y, 1.0f)); | |
} | |
if(SphereCollider != null) | |
{ | |
Gizmos.DrawWireSphere (transform.position, SphereCollider.radius); | |
} | |
Gizmos.color = oldColor; | |
} | |
void OnDrawGizmosSelected() | |
{ | |
Color oldColor = Gizmos.color; | |
Gizmos.color = color; | |
if(BoxCollider != null) | |
{ | |
Gizmos.DrawCube(transform.position, new Vector3(BoxCollider.size.x, BoxCollider.size.y, 1.0f)); | |
} | |
if(SphereCollider != null) | |
{ | |
Gizmos.DrawSphere (transform.position, SphereCollider.radius); | |
} | |
Gizmos.color = oldColor; | |
} | |
void OnTriggerEnter2D(Collider2D coll) | |
{ | |
Debug.Log(coll.gameObject.name + " entered " + gameObject.name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment