Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Can I stop Inputs with Events?

Discussion in 'Unity UI & TextMesh Pro' started by greg_hart, Jan 12, 2018.

  1. greg_hart

    greg_hart

    Joined:
    Nov 26, 2013
    Posts:
    3
    I'm controlling my orbiter camera through Input.GetMouseButton() (for rotate, pan, zoom) and my UI Buttons through Events and the Event Systems. What's the best way to prevent my camera from transforming while I'm dragging on a UI object listening to Events?? I've read that I should be using Events for UI and Input for things like camera manipulation, but let me know if there's a better way. Thanks for any tips!
     
  2. greg_hart

    greg_hart

    Joined:
    Nov 26, 2013
    Posts:
    3
    This nice video helped me find an answer:


    Essentially, transform the camera only if when the mouse/touch began, it wasn't over an EventSystem object.

    Code (csharp):
    1.    ((Input.touchCount == 1) && (Input.GetTouch (0).phase == TouchPhase.Began))) {
    2.             if (!EventSystem.current.IsPointerOverGameObject ()) {
    3.                 camXform = true;
    4.             } else {
    5.                 camXform = false;
    6.             }
    7.         }
    8. }
    Let me know if there are better strategies.