Okay so here is my code
In the Unity editor and when playing the text is in the correct place. I have the inspector set to 16:9. But when i compile it and select any resolution the text is in the wrong place and at a different size. Does anybody know how to fix this?
I googled it a bit and seen something to do with scaling with the screen res. But i dont know how to do that.
Thanks
Code
void OnGUI()
{
if (playerHealth >= 0)
{
GUI.Label(new Rect(10, 420, 200, 50), "Health = " + playerHealth.ToString("F0") + " %", healthTextStyle); // "10, 50, 200, 100)" is the location of the health bar
}
else
{
GUI.Label(new Rect(10, 420, 200, 50), "Health = 0%", healthTextStyle);
}
if (playerMass >= 0)
{
GUI.Label(new Rect(155, 420, 200, 100), "Mass = " + playerMass * 100+ " %", waterTextStyle);
}
else
{
GUI.Label(new Rect(155, 420, 200, 100), "Mass = 100%", waterTextStyle);
}
if (playerAcid >= 0)
{
GUI.Label(new Rect(155, 440, 200, 100), "Acid = " + playerAcid.ToString("F0") + " %", acidTextStyle);
}
else
{
GUI.Label(new Rect(155, 440, 200, 100), "Acid = 0%", acidTextStyle);
}
if (playerFire >= 0)
{
GUI.Label(new Rect(155, 460, 200, 100), "Fire = " + playerFire.ToString("F0") + " %", fireTextStyle);
}
else
{
GUI.Label(new Rect(155, 460, 200, 100), "Fire = 0%", fireTextStyle);
}
if (playerEnergy >= 0)
{
GUI.Label(new Rect(155, 480, 200, 100), "Energy = " + playerEnergy.ToString("F0") + " %", electricTextStyle);
}
else
{
GUI.Label(new Rect(155, 480, 200, 100), "Energy = 0%", electricTextStyle);
}
if (playerAmmo >= 0)
{
GUI.Label(new Rect(10, 440, 200, 100), "Ammo = " + playerAmmo, ammoTextStyle);
}
else
{
GUI.Label(new Rect(10,440, 200, 100), "Ammo = 0", ammoTextStyle);
}
if (coinCount >= 0)
{
GUI.Label(new Rect(10, 460, 200, 100), "Coins = " + coinCount, coinsTextStyle);
}
else
{
GUI.Label(new Rect(10, 460, 200, 100), "Coins = 0 ",coinsTextStyle);
}
if (playerScore >= 0)
{
GUI.Label(new Rect(10, 480, 200, 200), "Score = " + playerScore, playerScoreTextStyle);
}
else
{
GUI.Label(new Rect(10, 480, 200, 200), "Score = 0 " + playerScore, playerScoreTextStyle);
}
if (gameTime >= 0)
{
GUI.Label(new Rect(60, 400, 200, 200), "Game Time = " + gameTime.ToString("F2"), gameTimeTextStyle);
}
else
{
GUI.Label(new Rect(60, 400, 200, 200), "Game Time = 0:00", gameTimeTextStyle);
}In the Unity editor and when playing the text is in the correct place. I have the inspector set to 16:9. But when i compile it and select any resolution the text is in the wrong place and at a different size. Does anybody know how to fix this?
I googled it a bit and seen something to do with scaling with the screen res. But i dont know how to do that.
Thanks

