Search Unity

Stopping free look camera movement from touch UI clicks

Discussion in 'Cinemachine' started by mat-wright, Aug 28, 2017.

  1. mat-wright

    mat-wright

    Joined:
    Jan 17, 2017
    Posts:
    1
    Cinemachine is great, and the free look camera seems to work pretty much out of the box with mobile touch. However, I'm struggling to work out how to stop the free look cinemachine camera reacting to click events on buttons placed on a UI canvas.

    Any suggestions gratefully received.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    What? Nobody responded yet?

    So the GUI layer in Unity does not by default hide the mouse events from the input manager. If the input manager is reading the mouse and feeding it to the FreeLook, this will happen whether the mouse is on a GUI button or not.

    Your GUI handler needs to eat the event. See https://docs.unity3d.com/ScriptReference/Event.Use.html
     
  3. utsavsinh

    utsavsinh

    Joined:
    Apr 7, 2018
    Posts:
    2
    I'm having same issue please can you explain in detail how can I solve this, thank you
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    In the event handler for your button click, add event.Use(). That will prevent the event from getting propagated elsewhere.
     
  5. bauti_frigole

    bauti_frigole

    Joined:
    May 28, 2020
    Posts:
    2
    Hi, now I have the same problem and the event.Use(); doesn't work for me, it sends me a lot of errors, thanks.