• 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 VladimirRussia · Jul 23, 2011 at 09:49 PM · objectsonmouseup

Problems with OnMouseUp

Hello

I'm spawning several dozens of same objects using prefab from a script. The prefab has its own script assigned, which uses OnMouseUp(), however only two or so objects from all those spawned actually get OnMouseUp called for.

I double checked that they all have mesh colliders assigned. What could the problem be? :\

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
0

Answer by aldonaletto · Jul 24, 2011 at 03:08 AM

Have you checked the docs about OnMouseUp? OnMouseUp only is called if the mouse pointer didn't moved out of the collider or GUI element since the button was pressed. Could it be the problem? I mean: if the object is moving, you probably will loose it.
I personally prefer to use OnMouseOver - at least I've never had any problem with it:

function OnMouseOver(){
  if (Input.GetMouseButtonUp(0)){
    // do your stuff
  }
}

Another problem: I've heard about strange errors with mesh colliders, like objects disappearing when near to frustum planes. The problem seems to be with their bounds being incorrectly generated by Unity - who knows if it could interfere with mouse-to-object relation? Try to use box colliders or whatever just to test this possibility.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Sound won't PLAY!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1 Answer

objects going through each other 3 Answers

Grabbing Unity Objects via external applications 0 Answers

Networking Physics / Object Ownership / State Sync 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges