I have a GUI Orthographic camera which display a dynamic black box (for dialog), the GameObject’s scale is 1,1,1 which is a perfect square. The game screen will be dynamic in width, so sometimes it might be 1024, other times it might be 1920,
I am trying to determine an algorithm that will stretch this box according to the user’s screen that it covers the entire width. Again, this is a GameObject, I’m not using GUI.DrawTexture
Well you could check the screen coordinates, convert them to world coordinates and change the size x and y of the gameobject to match the x and y coordinates you got of the screen, or something like that :o
If you want DYNAMIC BOX that will fill whole screen no matter on resolution, then you have to do this
using UnityEngine;
using System.Collections;
public class MineMenu : MonoBehaviour
{
void OnGUI ()
{
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "This is the title");
}
}
You should set sizes of box when you’re making the box, don’t use variables because you can’t set “Screen.width” in class (I mean I had problems with that) if you have public variable maybe your settings in inspector overrides settings in code
like this:
....
public class MineMenu : MonoBehaviour
{
[COLOR="red"]private Rect BOX = new Rect(0, 0, Screen.width, Screen.height);[/COLOR]
void OnGUI ()
{
GUI.Box([COLOR="red"]BOX[/COLOR], "This is the title");
}
}
that is what I know about it, I had problem that I couldn’t make window for full screen