I’m using the Sprite Manager (as seen here http://forum.unity3d.com/threads/16763-SpriteManager-draw-lots-of-sprites-in-a-single-draw-call!).
I’m running into a problem though. My game involves a scrolling screen and an orthographic camera. The sprite manager is in an empty object at the screen center, once the camera scrolls too far to the left or right, all the sprites disappear, because the sprite manager object gets clipped out of the camera range.
So I’m implementing a strategy that involves linking the sprite manager object to the camera. This means that, without any other modification, the sprites move with the sprite manager, misaligning them from their respective objects. So in order to make the strategy work, I need to scroll the sprites in the opposite direction that the camera is moving.
I’m attempting to do this using the Vector3 v1 - v4 fields in the Sprite class. I do it from a function I built into the Sprite Manager:
public void UpdateSpritePositions(Vector3 inPosition)
{
for (int i = 0; i < sprites.Length; i++)
{
sprites[i].v1 = new Vector3(sprites[i].v1.x + inPosition.x, sprites[i].v1.y + inPosition.y, sprites[i].v1.z);
sprites[i].v2 = new Vector3(sprites[i].v2.x + inPosition.x, sprites[i].v2.y + inPosition.y, sprites[i].v2.z);
sprites[i].v3 = new Vector3(sprites[i].v3.x + inPosition.x, sprites[i].v3.y + inPosition.y, sprites[i].v3.z);
sprites[i].v4 = new Vector3(sprites[i].v4.x + inPosition.x, sprites[i].v4.y + inPosition.y, sprites[i].v4.z);
}
}
But so far this has only given really weird results, and I can’t seem to get a grasp on why, or how to do it right.
Can anyone with experience with the Sprite Manager tell me what I’m doing wrong?
Thanks in advance.