I’m having an issue where my app so far is working perfectly in Unity but after transferring it to an android tablet, it seems the co-ordinates I’m using to bind an area are off quite significantly.
2nd picture showing how the same bindings behave on an android device.
I am using ‘ScreenToWorldPoint’ with the mouse position in both instances. I can’t work out why there is a difference with the binding. The editor is set to using the same aspect ratio as the tablet device.
private void DrawMode() {
if (Input.GetKeyDown(KeyCode.Mouse0)) {
CreateBrush();
}
else if (Input.GetKey(KeyCode.Mouse0)) {
Vector2 mousePos = mainCam.ScreenToWorldPoint(Input.mousePosition);
Debug.Log("Before 'if':" + mousePos + _lastPos);
if (mousePos != _lastPos) {
Debug.Log("Into 'if'");
AddPoint(mousePos);
_lastPos = mousePos;
Debug.Log(mousePos + " " + _lastPos);
}
}
else if (Input.GetKeyUp(KeyCode.Mouse0)) {
RepositionLine(_currentLineRenderer);
}
else {
_currentLineRenderer = null;
}
}
private void AddPoint(Vector2 pointPos) {
_currentLineRenderer.positionCount++;
int posIndex = _currentLineRenderer.positionCount - 1;
_currentLineRenderer.SetPosition(posIndex, pointPos);
Debug.Log("AddPoint mousePos: " + pointPos);
}
Any assistance would be appreciated.