Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. 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.