ObjectLine
public class ObjectLine : MonoBehaviour
{
public SLine line = new SLine();
public SLine GetWorldLine()
{
SLine n = new SLine();
if(line != null)
{
n.point1.x = line.point1.x + (sfloat)transform.position.x;
n.point1.y = line.point1.y + (sfloat)transform.position.y;
n.point2.x = line.point2.x + (sfloat)transform.position.x;
n.point2.y = line.point2.y + (sfloat)transform.position.y;
}
return line;
}
}
A Unity component which holds a SLine to represent a line belonging to a Unity game object. You may use this line for simple line intersection tests against other shapes perhaps.
There are classes added to the editor folder so the line can be seen when a game object with this component is selected in the editor view in Unity.
Methods
public SLine GetWorldLine()
The SLine’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