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 liqvidb · Dec 18, 2014 at 01:37 PM · mouseclickclick and drag

Button's Click through problem? Help?

Hello! I am a novice in Unity and scripting. Of course I am having problems with lot of stuff. In my scene, I put some buildings and three cameras. On first camera I apply script for rotate on mouse drag and rotate on mouse scroll. Second camera auto rotates around the scene and third is First person camera. I use script for switching between cameras on three buttons. That all work very good but when i click on button and drag on it, camera in my scene is draging(rotating) to. I realize that i have click through problem. I am looking for a solution, reading other questions and answers but no luck for now.

Can someone help me on this please?

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 rob5300 · Dec 18, 2014 at 03:20 PM

If you are using the new 4.6 ui system, then make sure there is an EventSystem in the hierarchy. This is required to perform the internal ray casting to make UI objects intractable. If this is not the case, add a screenshot showing is the editor view with the button in question selected.

Edit: An EventSystem can be made by going to Create > UI > EventSystem.

Comment
Add comment · Show 4 · 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 liqvidb · Dec 18, 2014 at 09:25 PM 0
Share

Thanks for reply. I am using new UI sytem, and i have EventSystem in my scene. Can you give some information how can i make my UI objects intractable.

$$anonymous$$y scene contain: -Building, -cameras (autorotating, on drag/rotate scroll/zoom, and FPS Controller(buit in Unity) with camera) --Canvas>Plane>Three buttons that contain script's (for selecting active camera) and On Click () function in inspector view I select that button's as a game object's and attach function from script On$$anonymous$$ouseDown (). EventSystem

Thanks again, I am a begginer in Unity/Scripting, but I like to learn to do "simple" things like this.

avatar image rob5300 · Dec 19, 2014 at 10:28 AM 0
Share

From what you have said here, this should work fine. (You said Plane, do you mean an image?) When you click the button, does the button still activate as well as the camera movement, or is just the camera movement working? Please take a screenshot of your hierachy with the canvas children in view the button selected in the inspector.

avatar image liqvidb · Dec 19, 2014 at 12:13 PM 0
Share

I am sorry, i wrote "Plane", What I really wanted to write is "Panel". Button is working perfectly and camera movement is working when drag on button.! alt text

screenshoot.jpg (363.3 kB)
avatar image rob5300 · Dec 19, 2014 at 12:37 PM 0
Share

That's okay. I believe the reason this is happening is quite simple. I assume the method you use to rotate the camera is by using an if statement for Input.Get$$anonymous$$ouseButtonDown for left click. The code will still activate the code as the left click has happened, it doesn't care if it hits a button or not. If this is the case, you need to have the script that rotates the camera eathier disabled until required or also check if the correct mode is active. This should then restrict the camera panning to only when required.

Edit: I hope this is clear enough. Just remember that code looking for a left click will activate when a left click occurs. That is the problem in coding, you often have to be very specific in your code to prevent accidental firing.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Click and Drag not Clicking or Dragging 2 Answers

Access NGUI button's notify(OnClick) 1 Answer

Can I change GUIButton behaviour? 1 Answer

Convert vector in world to mesh 1 Answer

Remove a part of image on mouse click ? 1 Answer


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