Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by SabaorBust · Oct 05, 2015 at 10:54 AM · 2d gamemousemouseclick

Mouse Clicks Stop After X# of clicks

Having an issue with mouse clicks which register when I first start a scene, but stop soon there after.

Set up:

2D project Sprite w/ 2D BoxCollider (Is Triggerable) Straightforward DO Something Script (At bottom)

Click #1 - All is well - new object created

Click #2 - All is well - new object created

Click #3 - All is well - new object created

Click #4 - All is well .

Click #5 - nothing... nothing and more nothing

I've tried using both OnMouse, and Update -> RayCast ... both with the same result, mouse clicks stop after a certain number of clicks.

Help would be appreciated, Many thanks.

Quick Note - Forgot to mention -- If while mouse is not working I go back into the unity editor and DELETE the first 4 Clones instantiated, I can click 4 more times... then it stops again. Rinse Repeat.

 /*
 void OnMouseDown()
 {
     
     if (Input.GetMouseButtonDown(0))
     {
         var newGO = (GameObject)Instantiate(Resources.Load("PreFabs/HorseCart")); ;
     }
     
 }
 */
 
 
 public void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector2 mousePosition = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);
 
         RaycastHit2D hitCollider = Physics2D.Raycast(mousePosition, Vector2.zero, Mathf.Infinity);
 
 
         if (hitCollider && hitCollider.collider == ME)
         {
             var newGO = (GameObject)Instantiate(Resources.Load("PreFabs/HorseCart")); ;
         }
     }
 }


Comment
Add comment · Show 1
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 SabaorBust · Oct 05, 2015 at 07:30 AM 0
Share

After deleting, restarting re-adding everything in every combination imaginable - I believe I've narrowed down the problem to the 2D BoxCollider.

If I remove all the 2D BoxCollider and use a plain ole regular BoxCollider there "appears" to be no issue.

So...ok... 2D project + Code + 2D Assets + 3D BoxCollider = Work... 2D project + Code + 2D Assets + 2D BoxCollider = mouse throws a fit?

I thought for 2D project with 2D sprites and 2D everything that one was "supposed" to use 2D components?

0 Replies

· Add your reply
  • Sort: 

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

30 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 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

Mouse Cursor Problems,PLEASE HELP ME,I have cursor problems 0 Answers

Cannot instantiate 2D prefab on mouse click 1 Answer

Sprite/gameObject touch or click event 0 Answers

OnMouseDown and OnMouseUp but not OnMouseUpAsButton? 1 Answer

Need help with doing something in my game 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