(a public method variable)public Sprite tile_plain;
int i;
for (i=0;i<25;i++)
{
GameObject tile = new GameObject();
tile.AddComponent();
tile.GetComponent().sprite = tile_plain;
tile.transform.position = new Vector2((i * tile_plain.rect.width), 5f);
Then only one sprite element shows up on the screen and the others, while they are there are off the screen. To do this, you have to divide by the pixels per unit identified in the sprite.
(a public method variable)public Sprite tile_plain;
int i;
for (i=0;i<25;i++)
{
GameObject tile = new GameObject();
tile.AddComponent();
tile.GetComponent().sprite = tile_plain;
tile.transform.position = new Vector2((i * tile_plain.rect.width)/tile_plain.pixelsPerUnit, 5f);
This was a good Stackoverflow post (Unity 4.3 - understanding positions and screen resolution, how to properly set position of object?) on the topic.
No comments:
Post a Comment