I try place 10 cubes side by side with space like on image
[17720-gamescene.unity±+japanese+nonograms+unity±+iphone,+ipod+touch+and+ipad+2013-11-10+23-14-55.png|17720]
but i have problem – some time space between objects looks different.
My code for x cube position
float lastX = startPoint;
float offsetBetweanCubes = 0.3f;
for(int i=0; i < 10; i++) {
lastX += gameObj.GetComponent<MeshFilter>().mesh.bounds.size.x + offsetBetweanCubes;
Instantiate(gameObj, new Vector3(lastX, lastY, startPoint.z), Quaternion.identity)
}
is it way to fix this?
Triqy
2
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Transform prefab;
void Example() {
int i = 0;
while (i < 10) {
Instantiate(prefab, new Vector3(i * 2.0F, 0, 0), Quaternion.identity) as Transform;
i++;
}
}
}
The spacing is the same - what you’re seeing is the result of being zoomed out and having geometry not perfectly aligned to pixel edges.
You need to adjust the zoom of your camera to get the spaces to all appear the same. Also, if you maintain the same zoom at different resolutions, each resolution will appear different. If you can fix it for one resolution, then you need to maintain the same pixel ratio for geometry in other resolutions - by increasing or decreasing how much is on-screen (instead of scaling the scene according to resolution)