Skip to content

Instantly share code, notes, and snippets.

@dnkm
Last active August 29, 2015 14:17
Show Gist options
  • Save dnkm/389688998c811d71cba4 to your computer and use it in GitHub Desktop.
Save dnkm/389688998c811d71cba4 to your computer and use it in GitHub Desktop.
Gizmo Exampls
using UnityEngine;
using System.Collections;
public class Gizmo : MonoBehaviour {
public bool ShowMainCameraBorder;
void OnDrawGizmos() {
if (ShowMainCameraBorder) {
float z = GetComponent<Camera>().nearClipPlane;
Vector3 max = GetComponent<Camera>().ViewportToWorldPoint(new Vector3(1, 1, z));
Vector3 min = GetComponent<Camera>().ViewportToWorldPoint(new Vector3(0, 0, z));
Debug.Log(max.z);
Debug.Log(min.z);
Gizmos.color = Color.yellow;
Gizmos.DrawLine(min, new Vector3(min.x, max.y, z));
Gizmos.DrawLine(min, new Vector3(max.x, min.y, z));
Gizmos.DrawLine(max, new Vector3(max.x, min.y, z));
Gizmos.DrawLine(max, new Vector3(min.x, max.y, z));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment