Hi, (sorry for my english) I want move the mouse cursor with a gamepad. It's ok in Unity Editor and Windows Desktop (SetCursorPos API) but not for windows 10 store apps. I partially succeeded with this (very simplified): Code (CSharp): // x,y from GetAxis UnityEngine.WSA.Application.InvokeOnUIThread(() => { Point pos = CoreWindow.GetForCurrentThread().PointerPosition; Point newPos = new Point(pos.X - x * JoySpeed, pos.Y - -y * JoySpeed); CoreWindow.GetForCurrentThread().PointerPosition = newPos; }, false); The mouse movement is perfect but Unity don't update the mouse postion and all my RaycastHit2D (based on Input.mousePosition) over all GameObject (UI and other) are wrong. It's as if the mouse did not move for Unity. If i move my mouse physically (not in code) the capture is done correctly but not if I move it with the code above. My question is : how force Unity to capture the mouse position after my code ? Thank you for your help. Greetings.
Sounds like mouse move event was not fired. Only one thing comes to mind: try playing with Player Settings. Could be that you use independent input source, so changing cursor position for main view doesn't trigger event. Try other input options.
Hi Aurimas, Thank you for your answer. I made another system because I want the player to physically move the mouse cursor at any time and take over the gamepad, so I created a gameobject (Rect:top-left;32x32;anchors:0-1 all) in a canvas(size of screen) with a collider having the same size as the cursor (offset:16,-16;size:32,32) and that will move with it when the gamepad moves the mouse: Code (CSharp): //Vector2 mousePos; //double xyFactor = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; if (x != 0 || y != 0) { UnityEngine.WSA.Application.InvokeOnUIThread(() => { pos = CoreWindow.GetForCurrentThread().PointerPosition; Point newPos = new Point(pos.X - x * JoySpeed, (float)pos.Y - -y * JoySpeed); CoreWindow.GetForCurrentThread().PointerPosition = newPos; pos = new Point(newPos.X * xyFactor, screenHeight - (newPos.Y * xyFactor));//dips to pixels }, true); cursorObject.transform.position = new Vector3((float)pos.X, (float)pos.Y); } else if (mousePos != (Vector2)Input.mousePosition) cursorObject.transform.position = Input.mousePosition; mousePos = Input.mousePosition; If the player moves the cursor or presses a button with the gamepad the detection is done on the collider(or RaycastHit2D) of the cursorObject and not with mousePosition (not updated). This code is called only if the current player is playing with the gamepad. If it can help someone. Greetings.