- Home /
GUI.DrawTexture wrong on mobile build
Hello
I'm rendering lines with GUI.DrawTexture script
GUI.color = color;
GUI.matrix = translationMatrix(dz) * GUI.matrix;
GUIUtility.ScaleAroundPivot(new Vector2(m, width), new Vector3(-0.5f, 0, 0));
GUI.matrix = translationMatrix(-dz) * GUI.matrix;
GUIUtility.RotateAroundPivot(angle, Vector2.zero);
GUI.matrix = translationMatrix(dz + new Vector3(width / 2, -m / 2) * Mathf.Sin(angle * Mathf.Deg2Rad)) * GUI.matrix;
if (!antiAlias)
GUI.DrawTexture(new Rect(0, 0, 1, 1), lineTex);
else
GUI.DrawTexture(new Rect(0, 0, 1, 1), aaLineTex);
It's works very well in Unity IDE, but when I'm running mobile build on android my lines brokes and strart to glitch
Here's 2 screenshots from unity on windows and from my LG Optimus
http://answers.unity3d.com/storage/attachments/19695-linesviaunity.jpg
http://answers.unity3d.com/storage/attachments/19696-screenshot_2013-12-24-14-31-05.png
I had similar problem, but with different platforms. On OSx all ines are ok, on Windows start to have an offset. like the matrix or the texture coordinates are not the same
From what I am seeing, this may not be a problem with the DrawTexture call, but rather with the calculation of the line position. It looks like you are not calculating the difference in screen positions. As you can see the Vertical lines are all correct, but the horizontal lines are incorrect. This indicates to me that the draw texture is correct and the calculation is wrong. Perhaps post some additional code for the texture and line calculation.