Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Dogg · Aug 16, 2014 at 10:24 AM · guimouseonmouseenter

Why Is OnMouse Not Working Correctly?

Sorry for the generic always asked question, but my OnMouse isn't working correctly. On all the tutorials I've seen, when the person hovers over their GUI Textures, their script allows their textures to light up indicating that they're over it. But when I do it, it worked for most of the GUI Textures, but not all. If I remember correctly there are about two that don't work. One won't let me hover/click it at all, and another won't let me click it unless I go to the bottom of the screen, then it shows up. So what could be the problem? Are the GUI Textues too close to each other, or something else? Here's my script so I don't look crazy:

 public class Click : MonoBehaviour {
 
     public Texture2D normalTex;
     public Texture2D hoverTex;
     
     
     void OnMouseEnter(){
         
         guiTexture.texture = hoverTex;
         
     }
     
     void OnMouseExit(){
         
         guiTexture.texture = normalTex;
         
     }
     
     void OnMouseDown(){
         AudioManager.AudioInstance.PlaySound ("Sound");
         Application.LoadLevel("Scene1");
         
     }
 }

It's the script for the one that actually let's me click it, the other button has the same script except a different scene loader. Here is how my GUI Textures are arranged:

alt text

This is the one that I have to go all the way to the end of the bottom part of the screen(wow that was a lot of "the"). So it let's me click it, but not right on it. The other GUI texture that doesn't let me click on it uses the same structure. So what can I do? By they way I use OnMouse because I'm developing my game for IOS Ipad/Ipod touch.

mouseproblem.png (7.1 kB)
Comment
Add comment · Show 2
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 tanoshimi · Aug 16, 2014 at 09:14 PM 0
Share

"By they way I use On$$anonymous$$ouse because I'm developing my game for IOS Ipad/Ipod touch." How does one hover over a button on a touch device...?

avatar image Dogg · Aug 16, 2014 at 10:51 PM 0
Share

You don't. I'm simply using it because some have said that GUI Buttons are not very good with IOS. Can you confirm this? Although when you do click the texture, it still has the hover texture play. You just won't be able to see it for very long.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by brycem24 · Aug 16, 2014 at 07:24 PM

Two things, I believe that for IOS you can use Input.GetTouch. void OnMouseEnter should be changed to OnMouseDown. void OnMouseExit should be changed to OnMouseUp. and finally void OnMouseDown should be changed to OnMouseDrag.

Comment
Add comment · Show 2 · 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 Dogg · Aug 16, 2014 at 08:58 PM 0
Share

I'll try that, thanks for the suggestion. I'll come back and tell you if I got it working or not.

avatar image Dogg · Aug 16, 2014 at 11:18 PM 0
Share

Alight so I tried it. All it did was stop the mouse from being able to change the texture when hovering over it, it did not change how the buttons are click. The only difference is that now I can't tell if I've hovered over it, which isn't a problem since this is IOS, but I can't click the buttons directly. In order to click the bottom button, I have to click the bottom part of the screen. In order to click the middle, I have to click the top button. Finally in order to click the top, I have to click right above it.

By the way, I didn't use Input.GetTouch, as I don't know how.

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

23 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

Related Questions

Multiple Cars not working 1 Answer

Get Selected Object In Editor 2 Answers

Is it possible to link character skill lists to a GUI, and if so, how? 3 Answers

Gameover function calling before game ends help 2 Answers

Scene Selection 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