Running Linux Runtime without Window Manager workaround

Hello Unity Developers,

I’m writing this post regarding a recent bug discovered by our forum users where running the Unity Linux Runtime without a Window Manager (Example: X11 Window Manager) result in mouse input to break (Example: Mouse cursor not appearing in the runtime). First of all we would like to thank our users for bringing this issue to our attention.

After investigation we found out that, this issue was introduced with updating our SDL version. We rely on SDL to handle input related tasks in our engine. What is happening here is, Unity app is not rendering a cursor when running without a window manager using startx

We have found a workaround that could help you:

Note: This workaround require Unity Player to run in windowed mode.
In case, the app needs to be run in full screen mode. We can trick the player to run in the display’s native resolution by setting Default Screen Width and Default Screen Height parameters to match your display’s native resolution.
(Edit->Project Settings → Player tab)

Workaround : Forcing a cursor using Unity’s Cursor.SetCursor API
In the Start() function of your Unity script call Cursor.SetCursor API to set your cursor. This will force Unity app to render a cursor.
Example:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Text;
public class NewBehaviourScript : MonoBehaviour
{
    private Text box;
    public Texture2D c1, c2; // load textures to these vars from the inspector window
    // Start is called before the first frame update
    void Start()
    {
        box = GameObject.Find("box").GetComponent<Text>();
        Cursor.SetCursor(c2, new Vector2(0, 0), CursorMode.ForceSoftware);
    }
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.W))
        {
            box.text = "W Pressed";
        }
        if(Input.GetKeyDown(KeyCode.A))
        {
            box.text = "A Pressed";
        }
    }
}

We thank you again for bringing this issue to our attention and please feel free to contact us in this thread if you have any questions or need further assistance.