using UnityEngine;
using System.Collections.Generic;
namespace Cinemachine.Utility
{
/// Manages onscreen positions for Cinemachine debugging output
public class CinemachineGameWindowDebug
{
static HashSet mClients;
/// Release a screen rectangle previously obtained through GetScreenPos()
/// The client caller. Used as a handle.
public static void ReleaseScreenPos(Object client)
{
if (mClients != null && mClients.Contains(client))
mClients.Remove(client);
}
/// Reserve an on-screen rectangle for debugging output.
/// The client caller. This is used as a handle.
/// Sample text, for determining rectangle size
/// What style will be used to draw, used here for
/// determining rect size
/// An area on the game screen large enough to print the text
/// in the style indicated
public static Rect GetScreenPos(Object client, string text, GUIStyle style)
{
if (mClients == null)
mClients = new HashSet();
if (!mClients.Contains(client))
mClients.Add(client);
Vector2 pos = new Vector2(0, 0);
Vector2 size = style.CalcSize(new GUIContent(text));
if (mClients != null)
{
foreach (var c in mClients)
{
if (c == client)
break;
pos.y += size.y;
}
}
return new Rect(pos, size);
}
}
}