I’m having a hard time, tryng to understand how to get this working correctly.
I have a texture, of size 697x188, and i want to place this texture on the bottom right corner.
Although i got this working, once i change resolution, the gui texture also changes position.
I have it setup like this :
Pixel Inset
x = 0
y = 0
width = 697
height = 188
The borders all at zero
Position at zero
And in a script, on the Start function, i do the following :
Use of GUI matrices is for UnityGUI, not GUIText/GUITextures. As to your problem, you can try setting the transform.position values or manipulate the pixel inset values only (put object at 0,0,0). In either case you might need to monitor the screen size and at run-time make the necessary adjustments to keep the various elements where you want them.
Very simple and straightforward, and works with all resolutions. I use something like the code below, then adjust the adjustx and the adjusty to move the texture (which is referenced through the GUIstyle) wherever i want on screen (even the bottoom corner) (and then I stop the game and re-enter the numbers the asjustx and the adjusty in the inspector and re-save the scene) and it stays there for all resolutions, even in the bottom corner.
The texture in this case is 105 by 105 pixels and stretch in the GUIstyle is off.
var adjustx21 : float;
var TTF_GUI : GUIStyle;
//********************
GUILayout.BeginArea(Rect(Screen.width*adjustx21-105,Screen.height*adjusty21-105,Screen.width,Screen.height));
GUILayout.BeginHorizontal();
GUILayout.Button ("",texture_GUI)
GUILayout.EndHorizontal();
GUILayout.EndArea();
I make everything resolution-independent: ditch all the pixel inset stuff, and make the x scale (for example) .2 and the y scale .1. Then, to always be in the lower-right, the x position would be .9 and the y position would be .05. Done. Works with all resolutions, uses no scripting.
to Eric5h5
yes, it works for standalone app. But I have troubles in the window mode in web player - my logo got out the window. But when I run fullscreen mode - it works fine
Did you change all the pixel inset values to 0, and use the normal position and scale values only? I have no issues with any size window or screen when doing that, including the web player.
Haa!! I have found working parameters.
X axis position should be 1 (for bottom right corner) but X of Pixel inset shoud be the same as image Width but with opposite sign.
So now everithing is Ok with all resolutions and all players. 8)
@HiggyB - I understand that the way "manual"you said would be done as follows, if I want the application has 1024x768 I’ll have to manually make the positioning of GUI and so on, but when it is full screen as I proceed?
well, with scripting, you can do this, just use Screen.width - texture.width - 10 ect (this is in the OnGUI function, but I assume you can do this in any function, just change it a little)