Hello, im trying to make a game withouth the mouse, i mean, its not visible its only function is to move the camera), however, even if i disabled all the mouse clicks on keys (fire1,fire2,etc) if i click on the mouse it does stuff.
what my game uses are menues to navegate with WASD but if i click on the mouse any selected ui button is deselected and i cant re-select stuff. however i found a way to fix it, but it conflicts with another script i have for Tooltips
what the tooltip scrip does is check if the panel is enabled and then display information based on what button is currently selected.
NOTE: if i turn off the tooltips, then the script works good, and when i click on something i get to re-select stuff normally, but if i have tooltips turned on then it does nothing. and i get this error on console.
Also, button , button2, and button3 are never active at the same time, thats why i use them on the script, to make sure that theres always something selected.
"
NullReferenceException: Object reference not set to an instance of an object
Button1.Update () (at Assets/Zeker/Scripts/Button1.cs:297)
"
void Update()
{
if (tooltipPanel.gameObject.activeInHierarchy == true && gameOver == false)
{
if (EventSystem.current.currentSelectedGameObject.GetComponent<Button>() == defendButton)
{
tooltipText.text = "35 Energy. blabablablabalabla DEFENSE";
} else if (EventSystem.current.currentSelectedGameObject.GetComponent<Button>() == AttackMenu)
{
tooltipText.text = "25 Energy. "Attack in various ways blabalbal";
}
//the code continues for 15 more tooltips, but they are all the same code with different wording.
//reparar bug mouse
if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
{
CatchMouseClicks();
}
}
public void CatchMouseClicks()
{
if (button.gameObject.activeInHierarchy == true)
{
EventSystem.current.SetSelectedGameObject(button);
}
else if (button2.gameObject.activeInHierarchy == true)
{
EventSystem.current.SetSelectedGameObject(button2);
}
else if (button3.gameObject.activeInHierarchy == true)
{
EventSystem.current.SetSelectedGameObject(button3);
}
}