Version: 2021.3
言語: 日本語

Handles.DrawSolidRectangleWithOutline

マニュアルに切り替える
public static void DrawSolidRectangleWithOutline (Vector3[] verts, Color faceColor, Color outlineColor);

パラメーター

verts 矩形で使用するワールド座標の 4 つの頂点
faceColor 矩形の面の色
outlineColor 矩形のアウトラインの色

説明

3D 空間に太い実線の矩形を描画します。


Solid rectangle with a black outline in the Scene View.

// Create a semi transparent rectangle that lets you modify
// the "range" that resides in "SolidRectangleExample.cs"

using UnityEngine; using UnityEditor;

[CustomEditor(typeof(SolidRectangleExample))] public class DrawSolidRectangle : Editor { void OnSceneGUI() { SolidRectangleExample t = target as SolidRectangleExample; Vector3 pos = t.transform.position;

Vector3[] verts = new Vector3[] { new Vector3(pos.x - t.range, pos.y, pos.z - t.range), new Vector3(pos.x - t.range, pos.y, pos.z + t.range), new Vector3(pos.x + t.range, pos.y, pos.z + t.range), new Vector3(pos.x + t.range, pos.y, pos.z - t.range) };

Handles.DrawSolidRectangleWithOutline(verts, new Color(0.5f, 0.5f, 0.5f, 0.1f), new Color(0, 0, 0, 1));

foreach (Vector3 posCube in verts) { t.range = Handles.ScaleValueHandle(t.range, posCube, Quaternion.identity, 1.0f, Handles.CubeHandleCap, 1.0f); } } }

このハンドルにアタッチしているスクリプト

using UnityEngine;

public class SolidRectangleExample : MonoBehaviour { public float range = 5.0f; }