Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 08, 2013 at 03:01 PM by Entyro for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Entyro · May 05, 2013 at 08:01 PM · mousecursorlockcursor

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:

alt text

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.

alt text

1.jpg (59.1 kB)
2.jpg (57.9 kB)
Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jessy · May 06, 2013 at 04:20 PM 0
Share

Your tags need work. "HELP FAST!" is not appropriate for this site.

avatar image ExTheSea · May 06, 2013 at 06:54 PM 1
Share

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.

avatar image Entyro · May 06, 2013 at 07:22 PM 0
Share

Ah ok sorry for that! How about now? :)

avatar image ExTheSea · May 06, 2013 at 07:40 PM 0
Share

It's better. Do you have "Run in Background" checked (Under Edit-->Project Settings-->Player)?

avatar image ExTheSea · May 06, 2013 at 07:59 PM 1
Share

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 .

Show more comments

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges