Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【Unity】Viewportを利用したWorldPoint(position)の画面外のposition ref: http://qiita.com/shori0917/items/5c4a249ff09244645c93
public static Camera mainCamera;
public static float startWorldPointX;
public static float endWorldPointX;
public static float startWorldPointY;
public static float endWorldPointY;
void Start () {
mainCamera = GameObject .FindGameObjectWithTag("MainCamera" ).GetComponent <Camera> ();
// Viewポートの一番左のX座標
GM.startWorldPointX = GM.mainCamera.ViewportToWorldPoint(new Vector3 (0.0f, 1.0f, GM .mainCamera. nearClipPlane)).x;
// Viewポートの一番右のX座標
GM.endWorldPointX = GM.mainCamera.ViewportToWorldPoint(new Vector3 (1.0f, 1.0f, GM .mainCamera. nearClipPlane)).x;
// Viewポートの一番上のY座標
GM.startWorldPointY = GM.mainCamera.ViewportToWorldPoint(new Vector3 (0.0f, 0.0f, GM .mainCamera. nearClipPlane)).y;
// Viewポートの一番下のY座標
GM.endWorldPointY = GM.mainCamera.ViewportToWorldPoint(new Vector3 (0.0f, 1.0f, GM .mainCamera. nearClipPlane)).y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment