I have my user interface set up in a world space canvas. When I start the game up, one of the buttons is highlighted and I can use the arrow keys to cycle through the buttons and select the option that I want. The problem is that if the mouse clicks somewhere in the screen, the UI loses its focus. Is there someway that I can disable mouse input or make sure that the UI on my world space canvas is always selected?
I found a solution if anyone is interested. I wrote a script that selects a button if none are selected:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class selectButtons : MonoBehaviour {
public Button button;
public GameObject[] buttons;
private int activatedButtons;
// Use this for initialization
void Start ()
{
button.Select();
}
// Update is called once per frame
void Update ()
{
activatedButtons = 0;
foreach (GameObject i in buttons)
{
if(i == EventSystem.current.currentSelectedGameObject)
activatedButtons += 1;
}
if (activatedButtons < 1)
button.Select();
}
}