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
1
Question by imanik · Jun 18, 2015 at 06:26 AM · ui imagetouch controlsonmousedown

How to select an ui image with mouse click and touch?

I have selected ui>image and I want to select that image with mouse click and touch

i also added a script with that image obj:

// It works fine while start function Start(){ Debug.Log(gameObject.name); }

// It's not working function OnMouseDown(){ Debug.Log(gameObject.name);

}

no collider or mesh randerer or rigid body attached just a script is attached

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

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by Hellium · Jun 18, 2015 at 07:01 AM

You will have to deal with Events triggers if you want to keep the Image script only. By the way, I don't think it's a good practice to add a button script + Image this way (since the button can already display an image)

See tutorial on events triggers : https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-events-and-event-triggers

Otherwise, you could only keep the button script and put the target graphic as you did. In that case, you can just :

  1. Click on the "+" button under the "On Click" panel of the button script

  2. Put the object where the desired function must be called

  3. Select the script + function to call when a click is detected on your button

Comment
Add comment · Show 4 · 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 Hellium · Jun 19, 2015 at 07:53 PM 1
Share

@agosaravanan P Did it help ? Please, don't forget to feedback, others can face the same problem ! ;)

avatar image imanik · Jun 21, 2015 at 04:43 AM 0
Share

Thnx bro for ur ans. I just used event trigger method(pointer click) and added a script(myfunction) with that image obj now it works fine while I click on that obj.

avatar image Priyanshu · Jun 21, 2015 at 07:14 AM 0
Share

Please click on the tick mark. So others can know the answer is correct.

Click the Tick to mark the answer as correct.

unity-answer-tick.jpg (1.6 kB)
avatar image saravanan-P · Jun 22, 2015 at 04:40 AM 0
Share

What I suggested is working perfectly..

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Cannot get Image-based Touch Controller to Work 0 Answers

Check if an image has been clicked 1 Answer

Make touch buttons transparent 2 Answers

UI Image and OnMouseDown not working 3 Answers

Touch and Swipe at the same time mobile 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