- Home /
Simple question about OnMouseButtonAsUp
Hi. I would like to know if OnMouseButtonUp can be used for objects that the script is not a component to. If so, a basic example in JS would be appreciated.
No it cannot. You'll have to use some mechanism to communicate to other objects or use a Raycast() solution.
Answer by meat5000 · May 08, 2014 at 12:48 AM
Treat it (loosely) like a function that is called through hardware. Anything is possible.
In code you reference the other object and place your object-modifying code in the Event braces. (The Event being OnMouseButtonUp)
One last question. It now says on the On$$anonymous$$ouseUpAsButton scripting reference that it does not work with iPhone, but it works fine for me. I am aware it will not be able to get multiple touches but will it work?
You should avoid all $$anonymous$$ouse code for mobile device platforms. Use touch handling ins$$anonymous$$d. For cross platform, use platform dependent compilation directives.
It is ok to un-accept an answer if it turns out it didn't solve your problem.