It seems like this question has already been discussed many times. But I couldn't find the solution for my case. All the discussions are either about camera rotation according to mouse movement or object control via mouse. But I need to control the mouse pointer with joystick (or keyboard). It looks like a really simple question, but I'm confused. Currently, I'm trying to hide hardware cursor and recreat my own, controlling it with Input.GetAxis("Horizontal")
or Input.GetAxis("Mouse X")
but the cursor just disappears and Event System reports no movement. However, if I use Input.mousePosition.x
my custom cursor is well created and controlled with mouse. Unfortunately, I need to control it only with Joystick. In addition, it doesn't work with Project Settings>>Input (or maybe I'm change something wrong there) Thanks in advance.
public class cursor : MonoBehaviour
{
public Texture2D cursorImage;
private int cursorWidth = 32;
private int cursorHeight = 32;
public float horizontalSpeed = 2.0F;
public float verticalSpeed = 2.0F;
void Start()
{
Cursor.visible = false;
}
void OnGUI()
{
float h = horizontalSpeed * Input.GetAxis("Horizontal") * Time.deltaTime;
float v = verticalSpeed * Input.GetAxis("Vertical") * Time.deltaTime;
GUI.DrawTexture(new Rect(h, Screen.height - v, cursorWidth, cursorHeight), cursorImage);
}
}