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
0
Question by KpowKaEHoT · Dec 18, 2014 at 01:03 PM · windowscursor

How can I change system cursor in windows?

I want my application change cursor in windows when it's over some areas in my game. For example - always it's standart arrow and sometimes it's hand pointer. I tried do it with WINAPI using

     [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
     static extern int GetWindowLong(System.IntPtr hWnd, int nIndex);
     [System.Runtime.InteropServices.DllImport("user32.dll")]
     static extern System.IntPtr LoadCursor(System.IntPtr hInstance, int lpCursorName);
     [System.Runtime.InteropServices.DllImport("user32.dll")]

and do this

 hcursor = LoadCursor(System.IntPtr.Zero, (int)IDC_STANDARD_CURSORS.OCR_HAND);
 SetCursor(hcursor);

when I'm changing cursor

But it seems like OS changing it after me. I found this information

If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved.

on MSDN, but i can't find how to do it. Maybe there is simplier ways control system cursor on windows with unity?

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
0

Answer by SkaredCreations · Dec 18, 2014 at 01:06 PM

Is there a particular reason why you don't want to use Cursor.SetCursor (to reset to default just pass: null)? You can easily find a "hand" cursor texture over the web...

Comment
Add comment · Show 1 · 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 KpowKaEHoT · Dec 18, 2014 at 01:14 PM 0
Share

It will not work if user defined on his system custom cursors. For example dinosaur(like win xp) ins$$anonymous$$d of system hand. I want use something like C#-way System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

,Cursor is always in LOADING state (InputSystem 1.0.0, Win10 standalone + Legacy VR) 0 Answers

How do you detect if the cursor is visible within another window? 2 Answers

Does Unity 2.6 Pro support Windows 7 for standalone? 6 Answers

iPhone SDK on Windows? 1 Answer

Choppiness in Unity Editor but not on Build. 1 Answer


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