Assign action to UI button
I have this asset. It have number of acdtions like attacks, skills etc. I have 3 buttons. I need to assign to each button one attack. But I have no idea how to do it.
Attacks in this asset are in struct:
public struct Action
{
public string m_name; //Action Animation Name
public KeyCode m_keyCode; //Input Keycode
};
But function that performs the attack itself is bounded to animator:
// Check Action Input
private void UpdateActionControl()
{
int actionValue = 0;
for(int i = 0 ; i < m_actionList.Length ; i ++ )
{
if( Input.GetKey(m_actionList[i].m_keyCode) == true )
{
actionValue = i + 1;
break;
}
}
m_ani.SetInteger("Action", actionValue); //animator
}
Comment