I have created a GUI texture and added code for rollover effect and to process click. This is working fine. However, if I change the camera viewport to anything other than the default, the hotspot is appearing at a different place. I changed the Y parameter of the Normalized View Port Rect from 0 to 0.2. The image shifts to the relative center of the modified viewport, but the hotspot stays at the center of default viewport.
Am I doing anything wrong? How do I fix this problem?
I am attaching the code and images to replicate this issue:
var normalTexture : Texture2D;
var rollOverTexture : Texture2D;
var cursor : Texture2D;
var link : Texture2D;
var normal : Texture2D;
function OnMouseEnter(){
guiTexture.texture = rollOverTexture;
}
function OnMouseExit(){
guiTexture.texture = normalTexture;
Screen.showCursor = true;
cursor = normal;
}
function OnMouseOver () {
Screen.showCursor = false;
cursor = link;
}
function OnGUI () {
GUI.Label(Rect(Input.mousePosition.x-12, Screen.height - Input.mousePosition.y-10, 100, 100), cursor);
}
function OnMouseUp() {
print("Clicked!");
}
I need to change the viewport because, I am going to use multiple camera.