namespace UnityEngine.Rendering { /// /// Utility class for debug overlay coordinates. /// public class DebugOverlay { /// Current x coordinate. public int x { get; private set; } /// Current y coordinate. public int y { get; private set; } /// Current overlay size. public int overlaySize { get; private set; } int m_InitialPositionX; int m_ScreenWidth; /// /// Start rendering overlay. /// /// Initial x position. /// Initial y position. /// Size of overlays between 0 and 1. /// Width of the screen. public void StartOverlay(int initialX, int initialY, int overlaySize, int screenWidth) { x = initialX; y = initialY; this.overlaySize = overlaySize; m_InitialPositionX = initialX; m_ScreenWidth = screenWidth; } /// /// Increment coordinates to the next overlay and return the current overlay rect. /// /// Aspect of the current overlay. /// Returns a rect of the current overlay. public Rect Next(float aspect = 1.0f) { int overlayWidth = (int)(overlaySize * aspect); if ((x + overlayWidth) > m_ScreenWidth && x > m_InitialPositionX) { x = m_InitialPositionX; y -= overlaySize; } Rect rect = new Rect(x, y, overlayWidth, overlaySize); x += overlayWidth; return rect; } /// /// Setup the viewport for the current overlay. /// /// Command buffer used to setup viewport. public void SetViewport(CommandBuffer cmd) { cmd.SetViewport(new Rect(x, y, overlaySize, overlaySize)); } } }