お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closestart | ラインの開始位置(ワールド座標) |
end | ラインの終了位置(ワールド座標) |
color | ラインの色 |
duration | ラインを表示する時間(秒単位) |
depthTest | ラインがカメラから近いオブジェクトによって隠された場合にラインを隠すかどうか |
指定した開始位置と終了位置の間にラインを描画します。
ラインはエディターのシーンビューに描画されます。もしギズモの描画が有効になっている場合はゲームビューにも描画されるようになります。 duration
は命令を発行してからラインが描画され、消えるまでの時間(秒単位)です。durationが0の場合は1フレームのみ表示されます。
注意: これはプレイモードでデバッグするためのものです。エディタのギズモはこのAPIの代わりにGizmos.DrawlineまたはHandles.DrawLineで描画を行ってください。
// Frame update example: Draws a red line from the world-space origin to the point (1, 0, 0) for 1 frame. function Update () { Debug.DrawLine (Vector3.zero, Vector3 (1, 0, 0), Color.red); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Update() { Debug.DrawLine(Vector3.zero, new Vector3(1, 0, 0), Color.red); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Update() as void: Debug.DrawLine(Vector3.zero, Vector3(1, 0, 0), Color.red)
// Event callback example: Debug-draw all contact points and normals for 2 seconds. function OnCollisionEnter(collision : Collision) { for (var contact : ContactPoint in collision.contacts) { Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2, false); } }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void OnCollisionEnter(Collision collision) { foreach (ContactPoint contact in collision.contacts) { Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2, false); } } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def OnCollisionEnter(collision as Collision) as void: for contact as ContactPoint in collision.contacts: Debug.DrawLine(contact.point, (contact.point + contact.normal), Color.green, 2, false)