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

スクリプト言語

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

Handles.DrawDottedLines

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public static function DrawDottedLines(lineSegments: Vector3[], screenSpaceSize: float): void;
public static void DrawDottedLines(Vector3[] lineSegments, float screenSpaceSize);

パラメーター

lineSegments 線分の開始と終了を示す 1 組になった点の配列
screenSpaceSize ラインの長さとライン間の幅(ピクセル単位)

説明

含まれる線分を点線で描画します。

"スクリーンビューで複数の点線を描画します。"

以下の例では、リストで指定されたオブジェクトの間に 1 本の線を描画するために DrawDottedLine が使用されています。 この例を使用するには、以下のスクリプトを Assets/Editor フォルダーに保存します。


        
using UnityEngine;
using UnityEditor;

[CustomEditor( typeof( DrawDottedConnectedLines ) )] public class DrawDottedConnectedLinesEditor : Editor { void OnSceneGUI( ) { DrawDottedConnectedLines t = target as DrawDottedConnectedLines;

if( t == null || t.GameObjects == null ) return;

Vector3[] lineSegments = new Vector3[t.GameObjects.Length * 2]; int pointIndex = 0;

for( int i = 0; i < t.GameObjects.Length - 1; i++ ) { if( t.GameObjects[i] != null && t.GameObjects[i+1] != null ) { lineSegments[pointIndex++] = t.GameObjects[i].transform.position; lineSegments[pointIndex++] = t.GameObjects[i+1].transform.position; } }

Handles.DrawDottedLines( lineSegments, t.DashSize ); } }

このスクリプトを線の始点としたいアンカーオブジェクトにアタッチします。線の終点としたいゲームオブジェクトをスクリプトのインスペクターの配列にドラッグアンドドロップし、点線の間の差をそれぞれ調整します。


        
using UnityEngine;

[ExecuteInEditMode] public class DrawDottedConnectedLines : MonoBehaviour { public GameObject[] GameObjects; public float DashSize = 4; }

public static function DrawDottedLines(points: Vector3[], segmentIndices: int[], screenSpaceSize: float): void;
public static void DrawDottedLines(Vector3[] points, int[] segmentIndices, float screenSpaceSize);

パラメーター

points ポイントのリスト
segmentIndices 線分の開始と終了を示す 1 組になった点のインデックスの配列
screenSpaceSize ラインの長さとライン間の幅(ピクセル単位)

説明

インデックス化された線分を点線で描画します。

以下の例では、リストで指定されたオブジェクトの間に 1 本の線を描画するために DrawDottedLine が使用されています。 この例を使用するには、以下のスクリプトを Assets/Editor フォルダーに保存します。


        
using UnityEngine;
using UnityEditor;

[CustomEditor( typeof( DrawDottedConnectedLinesUsingPoints ) )] public class DrawDottedConnectedLinesUsingPointsEditor : Editor { void OnSceneGUI( ) { DrawDottedConnectedLinesUsingPoints t = target as DrawDottedConnectedLinesUsingPoints;

if( t == null || t.GameObjects == null ) return;

Vector3[] points = new Vector3[t.GameObjects.Length]; int[] segmentIndices = new int[t.GameObjects.Length * 2]; int pointsIndex = 0;

for( int i = 0; i < t.GameObjects.Length; i++ ) { if( t.GameObjects[i] != null ) points[pointsIndex++] = t.GameObjects[i].transform.position; }

for( int i = 0; i < pointsIndex - 1; i++ ) { int segmentIndex = i * 2;

segmentIndices[segmentIndex] = i; segmentIndices[segmentIndex+1] = i+1; }

Handles.DrawDottedLines(points, segmentIndices, t.DashSize ); } }

このスクリプトを線の始点としたいアンカーオブジェクトにアタッチします。線の終点としたいゲームオブジェクトをスクリプトのインスペクターの配列にドラッグアンドドロップし、点線の間の差をそれぞれ調整します。


        
using UnityEngine;

[ExecuteInEditMode] public class DrawDottedConnectedLinesUsingPoints : MonoBehaviour { public GameObject[] GameObjects; public float DashSize = 4; }