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 JohannChristoph · Apr 04, 2016 at 07:28 AM · uieventsystemdetect

detect any UI action

Is there a smart way to just detect any action of the new UI? Because I rotate my camera with mouse click and drag (or touch with one finger and drag) to look around. But when I use a UI slider for example I don't want the camera to rotate. I looked into the EventSystem and Modules, but I just don't get it how to apply it. Basically I just need to know if the mouse (or touch) is over an UI-element to set a boolean. Depending on true or false I want to block or allow the camera rotation.

Comment
Add comment · Show 4
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 meat5000 ♦ · Apr 04, 2016 at 10:35 AM 0
Share

Read the docs man! :P

https://www.google.co.uk/search?q=unity+onpointerenter&ie=utf-8&oe=utf-8&client=ubuntu&channel=fs&gfe_rd=cr&ei=cU$$anonymous$$CV8T8HtCFa$$anonymous$$zmtogF&gws_rd=ssl

The first hit has an example. O$$anonymous$$, I understand that you may not have found it as the example is under selectable.OnPointerEnter and the EventTrigger.OnPointerEnter is pretty empty!

There is also this, as found from a simple search.

http://answers.unity3d.com/questions/967170/detect-if-pointer-is-over-any-ui-element.html

avatar image meat5000 ♦ · Apr 04, 2016 at 10:54 AM 0
Share

After reading the material Ive linked, if you have trouble, edit this question and add your code; then you can get some proper help.

avatar image JohannChristoph meat5000 ♦ · Apr 04, 2016 at 06:50 PM 1
Share

Thank you! I'm sorry. I behaved stupidly with my searching. But after some trying I finally figured it out with the help of the second link and a little further research.

avatar image meat5000 ♦ JohannChristoph · Apr 05, 2016 at 02:21 PM 0
Share

"+1" to you friend.

I converted my answer to a comment. Accept your own answer and give a +1 to the answer through the link :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by JohannChristoph · Apr 04, 2016 at 07:09 PM

The second link (Detect If Pointer Is Over Any UI Element) is a good hint and a better way to put the question.

The function to use is EventSystems.EventSystem.IsPointerOverGameObject, which returns a boolean. An EventSystem with Input Module(s) needs to be present in the scene.

The Javascript code I use for my scenario is:

 static var myPointerIsOverUI : boolean; // my camera checks this before rotating
 
 function Update () {
 
     var ct : UnityEngine.EventSystems.EventSystem;
     ct = UnityEngine.EventSystems.EventSystem.current;
 
     if (ct.IsPointerOverGameObject()){
         myPointerIsOverUI = true;
     } else {
         myPointerIsOverUI = false;
     } 
 }
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

IPointerExitHandler while holding click 0 Answers

UI button not highlighting correctly 0 Answers

Which Joystick Pressed UI Button 1 Answer

Unity automatic UI navigation events get messed up after entering playmode 0 Answers

Unity 5.2 - How can I keep other players from using a menu? 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