3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Unity】Viewportを利用したWorldPoint(position)の画面外のposition

Last updated at Posted at 2014-02-25

##ソースコードの一部抜粋

using UnityEngine;
using System. Collections;

public class GM : MonoBehaviour {

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;
}

}

##参考画像
graphics_fundamentals_viewport_3dscene.png

##参考サイト
http://answers.unity3d.com/questions/589485/understanding-3d-world-and-gui-camera-space.html

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?