Transforms position from viewport space into world space.
// Draw a yellow sphere at top-right corner of the near plane
// for the selected camera in the scene view.
function OnDrawGizmosSelected () {
var p : Vector3 = camera.ViewportToWorldPoint (Vector3 (1,1, camera.nearClipPlane));
Gizmos.color = Color.yellow;
Gizmos.DrawSphere (p, 0.1);
}
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void OnDrawGizmosSelected() { Vector3 p = camera.ViewportToWorldPoint(new Vector3(1, 1, camera.nearClipPlane)); Gizmos.color = Color.yellow; Gizmos.DrawSphere(p, 0.1F); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def OnDrawGizmosSelected() as void: p as Vector3 = camera.ViewportToWorldPoint(Vector3(1, 1, camera.nearClipPlane)) Gizmos.color = Color.yellow Gizmos.DrawSphere(p, 0.1F)