Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Jul 13, 2018 at 02:45 PM by MrMarans for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by MrMarans · Jul 11, 2018 at 05:52 PM · c#uimouseiconhover

Change Mouse Icon on UI Hover

I want to change my mouse icon to another icon when I hover over an UI Element. The text-color is already changing, but Im not able to get the mouse icon to change. The Base Mouse Icon is the pencile, when hovering over the menu, it should change to the hand with the index finger.

My MouseChange code is as follows:

 public Texture2D defaultTextureMouse;
 public Texture2D exitTextureMouse;
 public CursorMode curModeMouse = CursorMode.Auto;
 public Vector2 hotSpotMouse = Vector2.zero;

 // Use this for initialization
 void StartMouse () {
     Cursor.SetCursor(defaultTextureMouse, hotSpotMouse, curModeMouse);
 }

 public void OnMouseEnter()
 {
     if (gameObject.tag == "exit")
     {
         Cursor.SetCursor(exitTextureMouse, hotSpotMouse, curModeMouse);
     }
 }

 public void OnMouseExit()
 {
     Cursor.SetCursor(defaultTextureMouse, hotSpotMouse, curModeMouse);
 }


I know that I have to make something with the EventTrigger. However, I dont know how to connect the script to the detection of hovering the mouse over any of the UI Text Elements. It isnt working with any Box Collider, because its a UI, right? I also dont know where to place the script to.

Picture shows that I have HyperTextEvents for the color to change from black to blue and back when hovering with the mouse. alt text

I hope you guys can help me and if you need any more informations, let me know. I hope i can answer them, because I just got that project without any documentation and im also new to 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

  • Sort: 
avatar image
2
Best Answer

Answer by Rajeesh_AR · Jul 12, 2018 at 05:17 AM

HI, For the UI, you have to include the "EventTrigger". Attach the MouseChange.cs script to a GameObject. Whatever be the object (either a new empty GameObject or even Camere). Pls check your code. The code which you copied here doesn't have the Class name.

Then select the UI component which you need to perform the MouseHover action. In that> Add Component > Event Trigger > Add New Event Type > PointerEnter > Click the '+' and drag and drop the GameObject in which you added your MouseChange.cs script. Select "OnMouseEnter".

Now, on the same UI element, Add Component > Event Trigger > Add New Event Type > PointerExit > Click the '+' and drag and drop the GameObject in which you added your MouseChange.cs script. Select "OnMouseExit".

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 MrMarans · Jul 12, 2018 at 11:55 AM 0
Share

Thank you so much. I didnt copied the the first 3 lines because i thought those are standard, doing it in future questions, anyway, thank you so much. It works now an now I even understand how this Event Trigger works. You are the best

Follow this Question

Answers Answers and Comments

152 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 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 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 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 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 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 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 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 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 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 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

PauseMenu - Camera moves in pausemenu 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

When touching the UI, it also affects overlapping game objects under the UI, causing the camera to move. How can I prevent it? 1 Answer

make an object glow when mouse over 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