Hi,
To get my viewer(GUI) always at the right size and position Im using that function:
void Start()
{
//ScreenRatio
horizRatio = Screen.width / 1920f;
vertRatio = Screen.height / 1080.0f;
print(Screen.width);
print(Screen.height);
print(horizRatio);
print(vertRatio);
}
//=========================================================================================================
void Update()
{
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ScreenRatio
//---------------------------------------------------------ScreenRatio
FSW = Screen.width;
FSH = Screen.height;
Ratio = FSW / FSH;
if ((Ratio) == (16.0f / 9.0f))
{
//Screen Ratio
SW = 1920f;
SH = 1080f;
//Pages
HelpX = 1084;
HelpY = 721;
LoadX = 300;
LoadY = 59;
//PhotoAlbum
.....
if ((Ratio) == (16.0f / 10.0f))
{
//Screen Ratio
SW = 1920f;
SH = 1200f;
//Pages
HelpX = 1084;
HelpY = 721;
LoadX = 300;
LoadY = 59;......
if ((Ratio) == (4.0f / 3.0f))
{
//Screen Ratio
SW = 1280f;
SH = 1024f;
//Pages
HelpX = 1084;
HelpY = 721;
LoadX = 300;
LoadY = 59;.....}
horizRatio = Screen.width / SW;
vertRatio = Screen.height / SH;
}
//=========================================================================================================
void OnGUI()
{
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Utilities
//Aspect Ratio
GUI.matrix = Matrix4x4.TRS(new Vector3(0f, 0f, 0f), Quaternion.identity, new Vector3(horizRatio, vertRatio, 1));
....
It always worked fine, but now I just redo a complete new viewer and some time It seems like it doesn’t rescale it so all my viewer is wrong.
If I press play with Maximize on Play everything is fine, if I didn’t select the Maximize on Play sometime it goes wrong sometime it doesn’t and if I manually scale the game window when it’s good it sometimes goes wrong and sometimes it fixed it.
I really don’t know what’s wrong everything is exactly the same as before…