- Home /
The question is answered, right answer was accepted
Alt+Tab pointer problem
Hi!
I have a problem when I'm "Alt+Tab", aka minimize, the game. After I minimized my game and then getting back in to it, some parts of the mouse pointer script doesn't work. The crosshair that I have moves around but it shouldn't. It should stay in the middle as it did before i "Alt+Tab" the game. It's like the "Screen.lockCursor = true;" changes to "false".
Anyone knows the problem?
Please help!
var myCursor:Texture2D;
var cursorSizeX: int = 32; // set to width of your cursor texture
var cursorSizeY: int = 32; // set to height of your cursor texture
function Start(){
Screen.showCursor = false;
Screen.lockCursor = true;
}
function OnGUI(){
GUI.DrawTexture (Rect(Input.mousePosition.x-cursorSizeX/2 + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY/2 + cursorSizeY/2, cursorSizeX, cursorSizeY),myCursor);
}
Before:
After: Hard to see with this picture, but when you move the mouse to look around, the crosshair moves around when it should stay in the middle.
Your tags need work. "HELP FAST!" is not appropriate for this site.
You should really provide more information. Nobody can help you with only those few information. You could for example post your code which is related to your problem.
It's better. Do you have "Run in Background" checked (Under Edit-->Project Settings-->Player)?
You could try but i don't think that it will do anything. Another idea: What should your code do exactly? If it's just keeping the Crosshair in the middle you can get the middle of the screen using Screen.width/2 and Screen.height/2 .
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Cant unlock cursor with FPS prefab 2 Answers
Trouble with unlocking cursor 1 Answer
FPS Controller Mouse not locking consistantly 0 Answers
MouseOver Doesn't work ON trigger 3 Answers