I'm doing the classic Aranoid 2D. I have 2 walls (Sprite Renderer) set at -7x and 7x. I have a method that calculates the distance between them, scales the bricks to adjust exactly in this range, and them instantiate them side by side, beginning from left wall and ending at right wall, resulting in 10 brick columns. Works perfectly at Editor.
However, when I did my first build to android, the last column is not being generated, leaving me with only 9 brick columns.
I created a script to camera, to force the aspect ratio 16/9, but didn't work. I have no clue what could be wrong.
Help!
![alt text][1]
Sample:
public List GenerateBricks()
{
var bricks = new List();
var sideWallWidth = this.RightWall.GetComponent().size.x;
var topWallHeight = this.TopWall.GetComponent().size.y;
var stageWidth = (this.LeftWall.transform.position - this.RightWall.transform.position).magnitude - sideWallWidth;
var brickWidth = this.Brick.GetComponent().size.x;
var brickHeight = this.Brick.GetComponent().size.y;
var columns = (int)(stageWidth / brickWidth);
var rows = this.Rows;
var origin = new Vector3(this.LeftWall.transform.position.x + sideWallWidth / 2 + brickWidth / 2,
this.TopWall.transform.position.y - topWallHeight / 2 - brickHeight / 2);
for (var c = 0; c < columns; c++)
{
for (var r = 0; r < rows; r++)
{
var b = Instantiate(this.Brick);
b.transform.position = new Vector3(origin.x + c * brickWidth, origin.y - r * brickHeight);
bricks.Add(b.GetComponent());
}
}
return bricks;
}
private void Awake()
{
this.camera = GetComponent();
this.camera.aspect = this.width / this.height;
}
[1]: /storage/temp/135688-sem-titulo.png
**Edit 1** : the problem also occurs on Windows Build
**Edit 2** : I did a build with "Development Build, Script Debug" enabled and it worked. Makes me more confuse than before!
↧