I’ve asked this question before but I still can’t figure it out. I have a lot of GUI Textures in my game which look perfect when the screen isn’t maximized. Here’s a picture
Use Pixel Inset to keep the same aspect ratio and/or prevent scaling, and to position the GUI elements relative to the edges of the screen.
For example, say that minimap/radar in the lower right is 128x128 pixels in size and offset 10 pixels from the lower right corner. Attach a script that includes something like this:
I tried it but I got this error:
Assets/GUILock.cs(1,6): error CS0116: A namespace can only contain types and namespace declarations
Here’s the script I made with my edited pixel pixel size
That script would need a little more around it, like a class definition. Here’s a better way, without having to use any scripts. You just have to set up your GUITexture a specific way:
Set the Transform’s Scale to (0,0,0).
Set the Position to (0,0,0) if you want anchor it to the lower left, (0.5,0.5,0) to center it, (1,1,0) in the upper right. You can mix up these values – for example, to anchor to the upper center, use (0.5,1,0).
Set the Pixel InsetWidth and Height to the pixel perfect size of your texture.
Adjust the Pixel Inset X and Y to position it exactly where you want. (Or adjust the transform’s Position to move it around a little proportional to the screen resolution.)