Make a chioce with Selectables and button UI objects
Hello everyone, I'm making a Lv Up menu. The player has to select which lv up he wants and then he has to press the accept button. I cannot figure out how to tell whist "selectable" is selected...
here is my code so far
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LevelUp : MonoBehaviour {
public GameObject LVUPmenu;
public Selectable Health;
public Selectable Attack;
public Selectable AttackSpeed;
public Selectable MovementSpeed;
public Button Accept;
void Start () {
Button accept = Accept.GetComponent<Button>();
accept.onClick.AddListener(TaskOnClick);
}
void TaskOnClick()
{
if (Health.*isSelected?*)
HPUp ();
else if (Attack.*isSelected?*)
ATKUp ();
else if (AttackSpeed.*isSelected?*)
ATKSPDUp ();
else if (MovementSpeed.*isSelected?*)
MOVSPDUp ();
}
Someone has any hint?
Comment