Hello guys!!
I’m just new in Unity game development and always find every posts and threads here helpful to my project
I’m currently working with a battle system which triggers the attack animation by the GUI.button event.
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.
This is a Question Answer type of Battle System
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.
Hope for anyone’s help with my first issue.
Thanks in advance