in my GUI im making everything proportional to the size of the screen its on, but for the smaller things like buttons it would seem easier if i could access the current window that the buttons are in’s width and height that change depending on the size of the screen.
what i want to know: is there a command for something like Screen.width/height, except its like window.width/height. ?
From the scripting reference (with a comment slipped in):
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Rect windowRect = new Rect(20, 20, 120, 50);
void OnGUI() {
windowRect = GUI.Window(0, windowRect, DoMyWindow, "My Window");
}
void DoMyWindow(int windowID) {
if (GUI.Button(new Rect(10, 20, 100, 20), "Hello World"))
print("Got a click");
// You can access windowRect here!
// GUILayout.Label ("This window is " + windowRect.width + " wide and " + windowRect.height + " tall");
}
}
thanks, but this didn’t really help that much, it wouldn’t re-size with the window it would make it really small and un-readable =\ i can post script so you know what im working with and im also having another problem but i want to get this one out of the way first
Rect winRect = new Rect(0, 0, 100, 100);
void OnGUI()
{
GUI.Window(0, winRect, doWindow, "Title");
}
void doWindow(int id)
{
// window code
}
float getWindowWidth()
{
return winRect.width; // this is, in essence, the width of the window
}
float getWindowHeight()
{
return winRect.height; // and this is the height
}