Handles.DrawSolidRectangleWithOutline

매뉴얼로 전환
public static void DrawSolidRectangleWithOutline (Vector3[] verts, Color faceColor, Color outlineColor);

파라미터

vertsThe 4 vertices of the rectangle in world coordinates.
faceColorThe color of the rectangle's face.
outlineColorThe outline color of the rectangle.

설명

Draw a solid outlined rectangle in 3D space.


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); } } }

And the script attached to this Handle:

using UnityEngine;

public class SolidRectangleExample : MonoBehaviour { public float range = 5.0f; }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961