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 Skatola · Jan 22, 2013 at 01:35 PM · functiononmousedown

two OnMouseDown function in the same obj, it's possible?

hi, sorry for my english :) my question is: can i have two differently "OnMouseDown functions" in the same object? if yes, how?

for example:

http://pastebin.com/45eUfqwS

ty :)

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Imankit · Jan 22, 2013 at 01:45 PM

Firstly you should use MouseButtonDown

And if you want to detect multiple touch use Input.Touch....

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 Skatola · Jan 22, 2013 at 02:13 PM 0
Share

ya...ok...but if i use $$anonymous$$ouseButtonDown function can i use it for 2 different functions?

avatar image Imankit · Jan 28, 2013 at 10:43 AM 0
Share

Input.Get$$anonymous$$ouseButtonDown(0) Input.Get$$anonymous$$ouseButtonDown(1)

You can use these two

avatar image
0

Answer by Owen-Reynolds · Jan 22, 2013 at 04:44 PM

Say you can click on a bomb to either explode it, or to pick it up. How will the computer know which one they want to do? Once you figure that out, you can program it.

Exs: suppose shift-click picks it up. Then check for the shift key in mouseDown. Suppose you have to pick it up, plant it, then blow it up. Start each bomb's planted=false, set to true when you plant it, and have mouseDown explode only if planted=true.

Comment
Add comment · 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
0

Answer by -hiTo- · Jan 28, 2013 at 11:08 AM

What you want to do is place the if-clauses inside the OnMouseDown() function. This way you only need 1 :)

 function OnMouseDown()
 {
     if (attivamazzoSM == true)
     {
         dadoFtrigger.TurnoF = true;
         dado44obj.renderer.enabled = true
     }
     if (greenarrow == true)
     {
         dadomantrigg.TurnoM = true;
         dado11obj.renderer.enabled = false;
     }
 }

To get the attivamazzoSM and the greenarrow bools to work, you need to make them fields in your class.

Comment
Add comment · 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
0

Answer by Skatola · Jan 28, 2013 at 03:48 PM

tnx a lot to all, problem solved :)

Comment
Add comment · 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

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

12 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

Related Questions

onMouseDown call function from other script 1 Answer

Making a var appear on click 1 Answer

function_parameters 1 Answer

I need "MainClass" 1 Answer

Invoke.Repeating doesn't really "care" about repeat time? 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