Version: 2022.3
言語: 日本語
public static void DrawLine (Vector3 start, Vector3 end, Color color= Color.white, float duration= 0.0f, bool depthTest= true);

パラメーター

start ラインの開始位置(ワールド座標)
end ラインの終了位置(ワールド座標)
color ラインの色
duration ラインを表示する時間(秒単位)
depthTest Determines whether objects closer to the camera obscure the line.

説明

指定した開始位置と終了位置の間にラインを描画します。

The line will be drawn in the Game view of the editor when the game is running and the gizmo drawing is enabled. The line will also be drawn in the Scene when it is visible in the Game view. Leave the game running and showing the line. Switch to the Scene view and the line will be visible.

The duration is the time (in seconds) for which the line will be visible after it is first displayed. A duration of zero shows the line for just one frame.

If depthTest is set to true then the line will be obscured by other objects in the Scene that are nearer to the camera.

Note: This is for debugging playmode only. Editor gizmos should be drawn with Gizmos.Drawline or Handles.DrawLine instead.

using UnityEngine;

public class ExampleScript : MonoBehaviour { void Start() { // draw a 5-unit white line from the origin for 2.5 seconds Debug.DrawLine(Vector3.zero, new Vector3(5, 0, 0), Color.white, 2.5f); }

private float q = 0.0f;

void FixedUpdate() { // always draw a 5-unit colored line from the origin Color color = new Color(q, q, 1.0f); Debug.DrawLine(Vector3.zero, new Vector3(0, 5, 0), color); q = q + 0.01f;

if (q > 1.0f) { q = 0.0f; } } }
using UnityEngine;

public class Example : MonoBehaviour { // Event callback example: Debug-draw all contact points and normals for 2 seconds. void OnCollisionEnter(Collision collision) { foreach (ContactPoint contact in collision.contacts) { Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2, false); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961