Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Alternative for Mouse Wheel (hosted in WPF after lost focus)

Discussion in 'Input System' started by LR-Developer, Jul 27, 2020.

  1. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Hello,

    for my business app my unity project is hosted in an wpf app.

    Mousewheel is working with both of these when I start, but after I clicked one WPF component like tab control or menu item, it is not working anymore:

    Input.GetAxis("Mouse ScrollWheel")
    Input.mouseScrollDelta.y

    I guess WPF is eating the event now...

    Other events like Input.GetMouseButton(1) are still working.

    Is there a way to get the Mouse Scroll Wheel Delta beside these?

    Thanks a lot!
     
  2. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    My fault:

    It is not the mouse wheel event which does not work, it is the keyboard!

    Code (CSharp):
    1. if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)
    This does not work at all, or at least it work initially but not after something in the WPF app was clicked.
    My unity project is hosted in a wpf contentcontrol and the process of the build app was started from the WPF app.

    All mouse events work fine, but the keyboard events are not working. Any chance to get them working, too?

    Thanks!
     
    Last edited: Jul 27, 2020