• 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 /
This question was closed Apr 11, 2016 at 07:57 PM by trillnoel for the following reason:

already asked

avatar image
0
Question by trillnoel · Apr 11, 2016 at 08:07 AM · mouseparentchildchildrenonmousedown

Is it possible to use OnMouseDown(collision other) ???

How do i delete this question?

Comment
Add comment · Show 2
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 Abhiroop-Tandon · Apr 11, 2016 at 08:56 AM 1
Share

I dont get what you are trying to do but what i think might help is use OnTriggerEnter(Collision collision) and inside it check for OnMouseDown() and put all the code in. What this will do is check the trigger when the mouse is down !!

avatar image trillnoel Abhiroop-Tandon · Apr 11, 2016 at 06:53 PM 0
Share

so does that mean that my collider has to be touching the object fruit two? im trying to mouse click on an instantiated prefab and check if the tag matches one of the inventory icons already. If it does match then instead of adding the icon to the panel it will increase the number on the icon that is already there. It works fine if I run into the object with my collider touches the fruits collider. But i want to convert my Collision checking to happen with the mouse click instead of me actually walking into the object.

1 Reply

  • Sort: 
avatar image
0

Answer by oscarlundberg · Apr 11, 2016 at 07:20 PM

Your mouse doesn't have a collider so it can't collide. I'm not sure what you want to do but maybe RaycastHit.Collider will work for you.

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 trillnoel · Apr 11, 2016 at 07:47 PM 0
Share

I have an object that I want to click on. Once it is clicked I want get the tag name. The object is a child. then debug log "I have clicked on object" .

avatar image trillnoel · Apr 11, 2016 at 07:48 PM 0
Share

But thank you that did answer one of my questions.

avatar image trillnoel · Apr 11, 2016 at 07:52 PM 0
Share

Here is the code now. Hello never prints.

void OnMouseDown() {

  Debug.Log ("hello");
  
   GameObject i;
   if(gameObject.tag == "fruit_one")
   { 
       i = Instantiate(inventoryIcons[0]);
       i.transform.SetParent(inventoryPanel.transform);
   }
  else if(gameObject.tag == "fruit_two")
   {
       i = Instantiate(inventoryIcons[1]);
       i.transform.SetParent(inventoryPanel.transform);
   }  
   else if(gameObject.tag == "fruit_three")
   {
       i = Instantiate(inventoryIcons[2]);
       i.transform.SetParent(inventoryPanel.transform);
   }

} }

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Make a simple tree 1 Answer

How to make multiple gameobjects child of one and the same transform (SCRIPT) 2 Answers

Deactivate Specific Children In Partent 1 Answer

Create Clones as children in loops? 1 Answer

Set up rank children 1 Answer

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