- Home /
Editor and Device resolution mixed-up problem
Good day guys!
So now I'm making my GUI for my game. I used a TextMesh and Textured Plane for this cause I think it's easier to position.
The Game Scene in my Editor is in 300x598, and my default orientation is Portrait. So I pre-positioned and pre-scaled them to a scale that it would look nice under the 300x598 Editor resolution.
I used this method to reposition and rescale and them:
void ScaleGUI()
{
float originalWidth = 300f, originalHeight = 598f;
float scaleX = Screen.width/originalWidth;
float scaleY = Screen.height/originalHeight;
scale = new Vector3(scaleX, scaleY, 1);
float positionX = 0f;
float positionY = 0f;
for(int i = 0; i < textures.Length; i++)
{
//textures[] are my Textured Plane GUI
positionX = textures[i].transform.position.x/originalWidth;
positionY = textures[i].transform.position.y/originalHeight;
textures[i].transform.localScale = new Vector3(textures[i].transform.localScale.x * scaleX, textures[i].transform.localScale.y * scaleY, textures[i].transform.localScale.z);
textures[i].transform.position = new Vector3(Screen.width * positionX, Screen.height * positionY, textures[i].transform.position.z);
}
}
When I tried it in Editor(300x598), there were no changes in the Transform which is correct.
But when I tried it in my Android Device(1024x600), the GUI elements that supposed to be in the upper part of the screen cannot be seen and the GUI elements in the center are not scaled normally.
Can you tell me what's wrong with this and what should I do? Thanks! :)
Your answer
Follow this Question
Related Questions
UGUI Scaling across multiple monitors 0 Answers
IOS Resolution Scaling 0 Answers
Huge Texture Not Keeping Resolution 1 Answer