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 Blue Blade Batoma · Nov 15, 2013 at 03:12 AM · click objects

OnMouseDown() Basic Help

I'm new to Unity and I am trying to use OnMouseDown() to register a click on a cube object. Basically, my code looks like

 function OnMouseDown(){
     Debug.Log("Clicked");
 }

This is the entire javascript file. There are no includes, no variables, and no other functions in it.

My scene consists only of a single cube with this script attached to it. I run the scene, but nothing happens when I click on the cube in either the game view or the scene view.

The cube is in the default layer and has a box collider. I have changed nothing about the project or scene apart from adding the cube.

I have been to several other questions but none of them seem to have the answer I am looking for. At this point, the only thing I can think of is that I forgot to include something when I created the project. Any thoughts?

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 Huacanacha · Nov 15, 2013 at 03:51 AM 0
Share

I just replicated this myself and it works fine. Empty scene, create cube with box collider, make sure it's in front of the camera, add script (with the same code you list above) to the cube. I click play then click on the cube and the Debug.Log prints out...

Sorry I can't see what your problem might be. $$anonymous$$aybe start with a fresh project to see what happens...

avatar image TheRaven · Nov 15, 2013 at 03:58 AM 0
Share

Your code and setup should work as described. Check that you have the box collider on the cube present and enabled.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Blue Blade Batoma · Nov 15, 2013 at 07:21 AM

Thanks for your answers. I figured out what's going on. I was getting an error every time I start Unity, but it didn't seem to make a difference. As it turns out, it is pausing my test of the scene after every frame, so my program hasn't actually been running.

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

18 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Click on two objects to render third 2 Answers

How do I let the player interact with objects close to them? 1 Answer

How to left click to rotate a box in a same direction in Unity 2D? 1 Answer

Make OnMouse functions ignore GameObjects that pass in front of them 1 Answer

How to click only one once? 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