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 /
avatar image
1
Question by DoctorChar · Apr 20, 2017 at 09:52 PM · imageui imagemouseclickonmousedownmouse position

Check if an image has been clicked

If this has been asked before and answered please point me to it.

I want so that when someone clicks an image, things happen. I want it to require a right click and only happen when you click on that one image. No rects because I cant get them to work.

Thanks!

Comment
Add comment · Show 1
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 toddisarockstar · Apr 21, 2017 at 03:46 AM 0
Share

are you asking if a GUI texture has been clicked or a game object has been clicked? 2d or 3d? this could be two entirely different questions.

what are you doing?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aklgupta · Apr 21, 2017 at 09:35 AM

I am not 100% certain what is it that you require, but I'll go with what i understood. If that image is a part of the UI/canvas, you can make it a button instead.

If it is a sprite, then add a Box Collider 2D to it, and attach a script with the follwoing function OnMouseUpAsButton()

eg.

private void OnMouseUpAsButton() { %|-524112790_1|% }

You can also use OnMouseUp() but I prefer OnMouseUpAsButton() You can read more about the function here https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseUpAsButton.html

or see more similar functions here, under the Messages heading https://docs.unity3d.com/ScriptReference/MonoBehaviour.html

Comment
Add comment · Show 3 · 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 DoctorChar · Apr 21, 2017 at 10:26 AM 0
Share

Thank you so much!

avatar image DoctorChar · Apr 21, 2017 at 10:29 AM 0
Share

Is there a way to do this externally, like from another object.

Thanks!

avatar image aklgupta DoctorChar · Apr 22, 2017 at 01:52 PM 0
Share

Well, it depends on what method you use, and what you want to do. There are many method to achieve what you want, or maybe none. I can't quite answer that without knowing what is it that you want. I'd suggest asking a new question, that way others more experienced than myself can also help you out.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Disable mouse input and cursor in game 2 Answers

I am building a missile defense game, i need a code that will fire missiles simultaneously at multiple mouse click positions. 0 Answers

Make images fit in UI 0 Answers

C# MOUSE EVENT TOGGLE 1 Answer

Find one image into another image 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