I am trying to create a row out of some square sprites I have. So to get the width of these sprites i am using
tileWidth = (int)tileSet[0].renderer.bounds.size.x;
And then to form the row i am uisng
for(int i = 0; i < tileSet.Length ; i++){
if((i+1)*tileWidth<screenWidth){
tileSet[i].transform.position = new Vector3(i*tileWidth,0,0);
}
}
But the sprites are still overlapping each other and do not form a proper row.
What am i doing wrong here and how can i rectify it?
If you are using Unity 5 you should use this code:
float tileWidth = tileSet[0].GetComponent<SpriteRenderer>().bounds.size.x;
Pay attention to your pixels per unit.