Last active
August 29, 2015 14:17
-
-
Save dnkm/389688998c811d71cba4 to your computer and use it in GitHub Desktop.
Gizmo Exampls
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 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