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 /
avatar image
3
Question by Joshua · Apr 18, 2011 at 05:12 PM · positionmousecursorlock

Lock mouse position with a Rect, possible?

I've been breaking my head looking for a way to lock the possible position of the mouse inside a Rect (basically, inside the webplayer's window, but I assume the solution would be the same).

The reason I think it should be possible is because it's also possible to lock the co-ordinates of the mouse to Screen.width/2,Screen.height/2.

Before you tell me to 'just lock the position and use a custom cursor texture that's locked inside the specified Rect', I've tried exactly that, and it does work. And sure, instead of using the mouseposition for things in game you cast a ray from the texture's position, etc. But you can no longer interact with the GUI buttons, which is a dealbreaker.

So if anyone would have any suggestions I'd be very, very, very thankful! I hope I was clear enough in explaining it.


Well, guess I'll make this a bounty then, since I'm really curious to see if this is somehow possible. :)

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Mike 3 · May 05, 2011 at 06:42 PM

It's not possible with the current API alone, LockCursor has very limited use there

It is however possible with a native plugin, but for that you're going to need unity pro and some c++/c/objc knowledge, depending on platform, as well as platform specific API knowledge

Comment
Add comment · Show 4 · Share
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 Joshua · May 05, 2011 at 08:01 PM 0
Share

Thanks for answering. Shame, I cannot afford Pro at this moment - being a poor student.. Guess I'll wait a little longer, and if no one else has a viable suggestion I'll accept your answer. ;)

avatar image Joshua · May 07, 2011 at 02:48 AM 0
Share

Hah, well I guess this is the easiest bounty you've ever won, congratulations :). Now I just need to magically figure out a way to get pro without going broke.. / mumbles something about being a poor student/ :p

avatar image Bunny83 · May 07, 2011 at 03:02 AM 0
Share

Even pro wouldn't help because native code plugins are not allowed in the webplayer. I don't see any way to implement that behaviour in the webplayer. Even if Unity extend the lockCursor functionality it will still be possible to break that limitation by pressing ESC. The only way i can see is that you do it with a custom cursor and handle the gui-events yourself. It's a nasty piece of work, but if you need the restrictions so badly that's at least a way ;)

avatar image Mike 3 · May 07, 2011 at 03:38 AM 0
Share

Oh, true, I hadn't seen the webplayer bit. A plugin would be useful with standalones at any rate.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Locking the mouse cursor without it centering after unlocking it? 0 Answers

Mouse cursor lock 0 Answers

Locking cursor without changing position 1 Answer

Disable/enable script and animation when you move your mouse cursor 1 Answer

Cant unlock cursor with FPS prefab 2 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