- Home /
Camera Panning 2d + Remote Build Vs Simulator
Currently I am working on a hidden object game where the user pans around a city scene. I have noticed two things that are different between when I run it through the simulator in Visual Studios and do a Remote build on my rt device. Currently I am using unitys sample ui for the main menu for the time being. Everything appears fine on the simulator for all resolutions. However when I put it on my device the source image attached to the buttons becomes shrunken. In the editor and on the simulator the button text will fill the image nicely but now it looks as if the text is the same size but my buttons have been scaled down. Secondly the code I have to pan on the device does not seem to work as it would on the simulator or editor in the sense that bounds in which it can pan seem shifted (essentially I would like the user to only be able to pan in the region where the background is,... but on the device they can pan into nothing and hence see a black empty screen if they pan enough).
Here is a portion of the code. Note my image is on a quad, this code is on my camera, and my Map is that quad.
void Start()
{
Sensitivity.x = .05f * map.localScale.x;
Sensitivity.y = .05f * map.localScale.y;
Sensitivity.z = .05f *(map.localScale.x + map.localScale.y);
float vertExtent = Camera.main.camera.orthographicSize;
float horzExtent = vertExtent * Screen.width / Screen.height;
float mapX = map.localScale.x;
float mapY = map.localScale.y;
minX = horzExtent - mapX / 2.0f;
maxX = mapX / 2.0f- horzExtent;
minY = vertExtent - mapY / 2.0f;
maxY = mapY / 2.0f - vertExtent;
minZ = .025f *(map.localScale.x + map.localScale.y);
maxZ = .05f* (map.localScale.x + map.localScale.y);
camera.orthographicSize = 10.0f;
}
//And a LateUpdate for bounding
void LateUpdate()
{
Vector3 v3 = transform.position;
float size = camera.orthographicSize;
v3.x = Mathf.Clamp(v3.x, minX + size, maxX - size);
v3.y = Mathf.Clamp(v3.y, minY + size, maxY - size);
camera.orthographicSize = Mathf.Clamp(camera.orthographicSize,minZ,maxZ);
transform.position = v3;
}
Should I trust what I am seeing on the simulator, or should I trust what I see when I do remote debugging on my device. Can anyone see a problem with any of the code I have posted, or know why I am seeing these strange things?