Its always the simple things that stump me grrr
I’m trying to position a window but it always starts at 0,0 and not at 200 x 200. I actually want it to be positioned on the right middle edge of the screen.
Heres my code.
var customSkin : GUISkin;
var winRect : Rect = Rect(200,200,150,200);
var scrollVec : Vector2 = new Vector2();
function OnGUI () {
GUI.skin = customSkin;
winRect = GUI.Window(0, winRect, windowFunc, "Answers");
}
function windowFunc(){
scrollVec = GUILayout.BeginScrollView(scrollVec);
GUILayout.Label (myString);
GUILayout.EndScrollView();
GUI.DragWindow();
}
Any help please?
Thanks
Its always the simple things that stump me grrr
I’m trying to position a window but it always starts at 0,0 and not at 200 x 200. I actually want it to be positioned on the right middle edge of the screen.
Heres my code.
var customSkin : GUISkin;
var winRect : Rect = Rect(200,200,150,200);
var scrollVec : Vector2 = new Vector2();
function OnGUI () {
GUI.skin = customSkin;
winRect = GUI.Window(0, winRect, windowFunc, "Answers");
}
function windowFunc(){
scrollVec = GUILayout.BeginScrollView(scrollVec);
GUILayout.Label (myString);
GUILayout.EndScrollView();
GUI.DragWindow();
}
Any help please?
Thanks
Change this:
var winRect : Rect = Rect(200,200,150,200);
to this:
var winRect : Rect = Rect(Screen.width/2,Screen.height/2,150,200);
that will make your window appear on the middle, dont know if that’s wht you are looking for… but hope it helps you
Hi
Thanks for posting. Unfortunately that doesn’t solve my initial problem. Its still at 0,0 when running in the editor, even with Screen.width…
The solution (Thanks NCarter in IRC) is that the vars are exposed to the inspector which doesn’t work for structures in this way.
All I had to do was make the vars private.
Doh!
Rofl yeah I’ve just saw it! hahaha
sometime happens to me as well hahaha1!!
Hmm, now that i have it working with exact values I tried to use Screen.width and its off screen!
e.g.
private var winRect : Rect = Rect( (Screen.width-200),0,150,100);
Is not on screen anywhere.
sigh
My bad,
you have to use values from 0 to 1 to set the window inside your screen, values > 1 will not show your window