using UnityEngine;
namespace SplashEdit.RuntimeCode
{
///
/// Represents a prohibited area in PlayStation 2D VRAM where textures should not be packed.
/// This class provides conversion methods to and from Unity's Rect structure.
///
public class ProhibitedArea
{
// X and Y coordinates of the prohibited area in VRAM.
public int X;
public int Y;
// Width and height of the prohibited area.
public int Width;
public int Height;
///
/// Creates a ProhibitedArea instance from a Unity Rect.
/// The floating-point values of the Rect are rounded to the nearest integer.
///
/// The Unity Rect representing the prohibited area.
/// A new ProhibitedArea with integer dimensions.
public static ProhibitedArea FromUnityRect(Rect rect)
{
return new ProhibitedArea
{
X = Mathf.RoundToInt(rect.x),
Y = Mathf.RoundToInt(rect.y),
Width = Mathf.RoundToInt(rect.width),
Height = Mathf.RoundToInt(rect.height)
};
}
///
/// Converts the ProhibitedArea back into a Unity Rect.
///
/// A Unity Rect with the same area as defined by this ProhibitedArea.
public Rect ToUnityRect()
{
return new Rect(X, Y, Width, Height);
}
}
}