You can add a delegate for the button to call it when it has clicked.
Example:
private void Awake()
{
Button buttonComponent = GetComponent<Button>();
buttonComponent.onClick.AddListener(OnButtonClicked)
}
private void OnButtonClicked()
{
Debug.Log("The button has clicked!");
}
You have to attach this script to your Button gameobject.
Also you can add the event function directly to your button directly via inspector, but the function should be public in order to be accessed by inspector. If you don't want your function to be seen by other classes, then the above would be your best choice.
In your case, Here's my suggestion:
[SerializeField]
private Button buttonE, buttonR;
private ComboInput input;
private void Awake()
{
buttonE.onClick.AddListener(OnButtonClicked_E);
buttonR.onClick.AddListener(OnButtonClicked_R);
}
private void OnButtonClicked_E()
{
input = new ComboInput(AttackType.heavy);
}
private void OnButtonClicked_R()
{
input = new ComboInput(AttackType.light);
}
EDIT: If what you want is editing your existing combat script (not creating a new individual component), then you have to give your buttons to your combat script. That is buttonE, buttonR, which you have to give a reference via unity inspector. If it has done, then you're free to remove your Update() function, if there are no other things related to it.