I have problems with a texture. I’ve placed at the top of the screen, however when I change the resolution shrinks or expands too. How can I do so that when the screen resolution (Android in this case) is being resized to 480X320 the texture? I tried it with Screen.setResolution but does not work. Tips? thanks =)
You didn’t finish that question. What do you want?
You may use GUI.DrawTexture and set rect’s size to your resolution size (Screen.width, Screen.height):
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), texture);
If it doesn’t suit, explain what you mean.
I wrote this:
GUI.DrawTexture(Rect(10,40,80,130), aTexture[0], ScaleMode.StretchToFill, true, 10.0f);
The problem is that it is adapted to a screen 1024 x 600. If the screen 480X320 imposed on it, the texture is too large. I wanted to resize the texture depending on which device.
If you want it to be positioned at the same place relative to all screen resolutions then you will use percentages.
step 1:
Choose your ideal resolution ( this is the resolution that you will design your whole UI layout around ). So in your case, 480x320.
step 2:
Determine what percentage from the left edge of the screen your texture is positioned. So if it is positioned at (20,20) on 480x320 resolution, that will mean its percentage position will be: (20/480 , 20/320) . This means it is positioned 0.04167% from the left of the screen, and 0.0625% from the top of the screen.
step 3:
Now you can use this information to place the texture at exactly the same place relative to all resolutions by using the current Screen dimensions:
newPosition = (percentX * Screen.Width, percentY*Screen.Height).
step 4:
Use this same method to determine the percent of scaling of the image. So your texture is pixel perfect on all resolutions. However, you will need to take into account different aspect ratios, of both the screen and the texture, which can be tricky if you do not fully understand the math.