What I want to have is how can I immediately disable the GUI button when I click it so that it will not trigger another another attack function.
Here’s my code:
void OnGUI()
{
...
battleQ = GUI.Window(2, battleQ, battleWin,"Tasyo",battleSkin.window);
}
void battleWin (int winID)
{
...
if (slash == true)
GUI.enabled = true; // enables the GUI button to make attack
else
GUI.enabled = false;
if(GUI.Button(AttackB,">"))
{
slash = false;
GUI.enabled = false;
//player attack
if (atake == true)
{
bida.transform.position = new Vector3(319,10,271);
playerAnim.SetBool("idle2ToIdle1", true);
}
else
{
playerAnim.SetBool("idle2ToIdle0", true);
}...
What happen is, when I click the GUI.button. it does the animation, but the button is still active.
This give a enables the Gui button to be clicked again even if the execution of animation and some functions are not done. And when it does, It jams the battle system.
The GUI.button only disable when it’s done executing the code… if I’m not mistaken.
Thanks in advance