Hi, Ive got a script that allows my picture to change from the size of the plane it’s on to full screen on mouse down. The problem is once its full screen it doesn’t exit on mouse down when clicked again. I’ve been looking around to find a way but to no avail. Heres the code:
var showing: boolean;
var currPic: Texture2D;
var exitButtonRect: Rect;
function OnGUI () {
if (!showing) return;
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), currPic);
if (GUI.Button(exitButtonRect, "Exit")) {
showing = false;
}
}
function ChangePicture(newPic: Texture2D) {
showing = true;
currPic = newPic;
}
Is it because I’m missing a GUI button called Rect? I don’t want a button I just want to exit full screen on click. Please help if you can
Can you post your mouse click code ?
I presume the problem is that you are using a collider on the pic and expecting
the collider to resize to fullscreen along with the pic.
When the pic goes fullscreen, you can just set a flag to true and
detect mouse down in Update using Input.GetMouseButtonDown.
This is the mouse click code. I understand the theory behind what your saying, that when my pic goes full screen the collider doesn’t but I don’t understand “set a flag to true and detect mouse down in Update using Input.GetMouseButtonDown.” This is in Java script but I definitely prefer C# so if you happen to have the coding in C# I’d love to have it.
I should also mention that I have a Lock Cursor script that centres my cursor mid screen so I can only click mid screen.
var myPic: Texture2D;
function OnMouseDown() {
SendMessageUpwards("ChangePicture", myPic);
}