To draw on the scene, you can draw using the EditorGUI and its methods, for example DrawRect, in the usual OnGUI method. It looks like this:
public static void DrawRect(Rect rect, Color color);
that is, it accepts an object of type Rect as input and paints it in Color . The simplest form would be:
void OnGUI() { Rect rect = new Rect(0, 0, 300, 300); Color color = Color.blue; EditorGUI.DrawRect(rect, color); }
Accordingly, for all the rectangles in the list, it is enough to go over it and draw, such as
Color color = Color.blue; foreach (var rect in list) { EditorGUI.DrawRect(rect, color); }
In the Scene tab, you can use the OnDrawGizmos method and draw rectangles using Gizmos.DrawGUITexture . Accordingly, it is necessary to set the texture to a rectangle.
public Texture2D texture2D; // Тут будет текстура, хотя бы просто материал красный void OnDrawGizmos() { foreach (var rect in list) { Gizmos.DrawGUITexture(rect, texture2D); } }
Or in the same place to draw at the expense of Gizmos.DrawCube , simply taking coordinates from rect
void OnDrawGizmos() { // Задаем цвет рисуемого предмета !!! Color color = Color.red; foreach (var rect in list) { Gizmos.DrawCube(rect.position, rect.size); } }