Version: 5.5

Handles.DrawAAConvexPolygon

Switch to Manual
public static void DrawAAConvexPolygon (params Vector3[] points);

Parameters

points List of points describing the convex polygon.

Description

Рисует сглаженную линию, указанную массивом точек и шириной.

The following example uses DrawAAConvexPolygon to draw an arrow between two objects in the Scene view.

To use this example, save the following script in the Assets/Editor folder:

using UnityEngine;
using UnityEditor;

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

if (t == null || t.From == null || t.To == null) return;

Vector3[] arrowHead = new Vector3[3]; Vector3[] arrowLine = new Vector3[2]; Vector3 start = t.From.transform.position; Vector3 end = t.To.transform.position;

Vector3 forward = (end - start).normalized; Vector3 right = Vector3.Cross(Vector3.up, forward).normalized; float size = HandleUtility.GetHandleSize(end); float width = size * 0.1f; float height = size * 0.3f;

arrowHead[0] = end; arrowHead[1] = end - forward * height + right * width; arrowHead[2] = end - forward * height - right * width;

arrowLine[0] = start; arrowLine[1] = end - forward * height;

Handles.color = Color.red; Handles.DrawAAPolyLine(arrowLine); Handles.DrawAAConvexPolygon(arrowHead); } }

...and attach the following script to a GameObject in the Scene. Drag and drop GameObjects onto the From and To inspectors, corresponding to the GameObjects where you would like to see the arrow drawn:

using UnityEngine;

[ExecuteInEditMode] public class DrawArrow : MonoBehaviour { public GameObject From, To; }