• 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
Question by Posthuman-Wizard · Dec 05, 2012 at 10:13 PM · guiinputguitextureonmousedownguielement

GUITexture and GameObject OnMouseDown() Problem

alt text

Greetings. I am having difficulty trying to figure out how to click on a GUITexture onscreen without activating a GameObject's OnMouseDown() if that GameObject is covered by the GUITexture. The idea is that I click on the GameObject, which brings up a menu above it (The GUITexture(s)) that I can interact with; however, clicking on the GUITexture(s) seems to activate the OnMouseDown() of the GameObject, which intentionally causes the menu to disappear (I only want the menu to disappear when the part of the object that is showing is clicked; otherwise, I'd like anything covered by the menu to not be activated). What is the best way to fix this problem?

demonstration.png (42.3 kB)
Comment

People who like this

0 Show 0
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

Answer by Dexter.Unity · Dec 05, 2012 at 10:29 PM

I think you should place the GUI script parts on you camera.

Then on click of the game object make a boolean true, which will make you see the GUI.

Your GUI will be part of the Camera on which you can't click.

Comment

People who like this

0 Show 6 · 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 Dexter.Unity · Dec 05, 2012 at 10:30 PM 0
Share

Ohh wait the GUI text has to be INSIDE the 3d environment?

In that case you shouldn't make the GUI text a child of the GameObject but just stand next to it (in the Hierarchy)

avatar image Posthuman-Wizard · Dec 05, 2012 at 10:39 PM 0
Share

The menu is not parented to anything in the hierarchy. It is a separate GUIElement that, in the viewport, is "covers" other GameObjects with OnMouseDown() functions. I want to be able to click on the menu without activating the separate, unrelated GameObject beneath it's OnMouseDown() function.

avatar image Dexter.Unity · Dec 05, 2012 at 10:59 PM 0
Share

I don't know exactly how to prevent the OnMouseDown of the other objects. But you can add a boolean in the script that triggers the menu hide. This boolean is false when the menu is opend and true when it's closed. This way the script will know the menu's status and won't execute the close menu when the menu is opend

avatar image Dexter.Unity · Dec 05, 2012 at 11:00 PM 0
Share

Or do you want other objects to close the menu when it's not hovering? x)

avatar image Posthuman-Wizard · Dec 05, 2012 at 11:04 PM 0
Share

My intent is to click on other GameObjects nearby the one that I clicked on to reposition the menu and populate it with information pertaining to those GameObjects. Basically, I click on a GameObject, it sends a message to the menu script (Which is attached to the camera) telling it to open, and I should be able to interact with it, without calling the OnMouseDown() of the things it is covering. If I click on the uncovered portion of the GameObject that originally told the menu to open, then the menu should close. If I click on any other GameObject while it is open, again, the menu should move to its viewport position and display the relevant information. The GameObjects are all tightly packed in the world space.

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

How to control GUITextures within a single C# script? 1 Answer

Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer

Help! Hiding/showing GUITextures! 1 Answer

Samsung 42" Touch Screen: Touch response issues 1 Answer

GUITexture KeyInput 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