Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Camera.ScreenToWorldPoint

マニュアルに切り替える
public Vector3 ScreenToWorldPoint(Vector3 position);

パラメーター

説明

Transform position のスクリーン座標からワールド座標に変換します。

スクリーン座標はピクセル単位で定義されています。画面の左下は(0, 0)、右上は 右上は ( pixelWidthpixelHeight) になります。Z 位置はワールドユニットでカメラからの距離になります。

	// Draw a yellow sphere in the scene view at the position
	// on the near plane of the selected camera that is
	// 100 pixels from lower-left.
	using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnDrawGizmosSelected() { Camera camera = GetComponent<Camera>(); Vector3 p = camera.ScreenToWorldPoint(new Vector3(100, 100, camera.nearClipPlane)); Gizmos.color = Color.yellow; Gizmos.DrawSphere(p, 0.1F); } }