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 WilliamJung · Apr 28, 2014 at 12:15 PM · texturemouseclick

OnMouseDown() is not working in the GUITexture

Follwing module is attached in GUITexture, however there is no reaction in OnMouseDown(). Please help me. I couldn't find any proper answer in this page.


 using UnityEngine;
 using System.Collections;
 
 public class SceneMove : MonoBehaviour 
 {
     public string SceneName;
 
     public void OnMouseDown(){
         print ("LoadLevel");
         Application.LoadLevel( SceneName );        
     }
 
     void update()
     {
     }
 }
Comment
Add comment · Show 5
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 HarshadK · Apr 28, 2014 at 12:28 PM 0
Share

I tested your code and it works. So please specify what is the exact output that you expect.

avatar image SuperMasterBlasterLaser · Apr 28, 2014 at 12:41 PM 0
Share

Have you added any colliders? In know that On$$anonymous$$ouseDown will work if your GameObject got some kind of collider

avatar image Eric5h5 · Apr 28, 2014 at 01:40 PM 0
Share

@Super$$anonymous$$asterBlasterLaser: that's not correct; GUIText and GUITexture objects do not require colliders.

avatar image WilliamJung · Apr 28, 2014 at 01:53 PM 0
Share

Thank you for your answer,as above answer, GUITexture is not needed collider. I have wresled with this error for hours. But not found the solution.

avatar image Eric5h5 · Apr 28, 2014 at 08:47 PM 0
Share

Well, it works fine here. Try making a new empty project, create a GUITexture, and attach the script. You'll see it works as expected.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Calum-McManus · Apr 28, 2014 at 01:22 PM

there are no errors in your code, the only thing that it could be is that you are not clicking on a Collider. if you want this to work when ever you click, just put a box taking up the whole screen then turn of its renderer and attach this script to it.

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 Eric5h5 · Apr 28, 2014 at 01:43 PM 0
Share

GUITexture objects don't use colliders.

avatar image Calum-McManus · Apr 29, 2014 at 09:29 AM 0
Share

Indeed, it should work on a GUI layer object or a collider, my advice would be to use a collider ins$$anonymous$$d if you really can't get a GUI-texture to work, although it should and has worked when I tested it. You could always try doing the OnGUI function and make a texture layer using that and see if it works.

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

24 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

Related Questions

Trying to pick up and see paper - pop up GUI window to examine objects when clicked 3 Answers

Change button texture when its clicked 1 Answer

Changing texture on mouse click 1 Answer

Assigning UV Map to model at runtime 0 Answers

Terrain texture low quality 0 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