ObjectRect
public class ObjectRect : MonoBehaviour
{
public SRect rect = new SRect();
public SRect GetWorldRect()
{
SRect n = new SRect();
if (rect != null)
{
n.position.x = rect.position.x + (sfloat)transform.position.x;
n.position.y = rect.position.y + (sfloat)transform.position.y;
n.w = rect.w;
n.h = rect.h;
}
return n;
}
}
A Unity component which holds a SRect to represent a rectangle belonging to a Unity game object. This could easily represent all sorts of things in your game world. It could represent the solid things in the world, the collision box of your NetworkEntities or even your damage or hitboxes to help in combat type games.
There are classes added to the editor folder so the circle can be seen when a game object with this component is selected in the editor view in Unity.
Methods
public SRect GetWorldRect()
The SRect’s x,y positions are relative the game objects, however this method converts that position to world coordinates so it can be used correctly in any mathematical calculations