Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- using UnityEngine;
- namespace Game.Utilities
- {
- public class RectDrawer
- {
- private const float Offset = 2f;
- private readonly IRectLineDrawer[] _drawers;
- private readonly int _length;
- public RectDrawer(params IRectLineDrawer[] drawers)
- {
- _drawers = drawers;
- _length = _drawers.Length;
- }
- public void Draw(Rect position)
- {
- var current = new Rect(position) { height = EditorGUIUtility.singleLineHeight };
- for (int i = 0; i < _length; i++)
- {
- IRectLineDrawer drawer = _drawers[i];
- drawer.Draw(current);
- float currentY = i != _length - 1
- ? EditorGUIUtility.singleLineHeight + Offset
- : 0;
- current.y += currentY;
- }
- }
- public float Height => _length * EditorGUIUtility.singleLineHeight + (_length + 1) * Offset;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement