Search Unity

Buttons animations

Discussion in 'Scripting' started by gagac42, Jan 21, 2019.

  1. gagac42

    gagac42

    Joined:
    Apr 24, 2018
    Posts:
    119
    Hello i have problem my input not work and i not know why ....my console not write error .... my Project settings input have buttons pls help my i not know fixed error here is my script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class DanceAnimation : MonoBehaviour
    7. {
    8.  
    9.     public Animator Anim;
    10.     public string[] NameAnim;
    11.     public int BoolInt;
    12.     public Button[] Buttons;
    13.  
    14.    public void AnimationsButton()
    15.     {
    16.  
    17.         Anim.SetBool("Dance", true);
    18.            
    19.      }
    20.  
    21.     void Update()
    22.     {
    23.  
    24.         if (Anim.GetBool("Dance") == false)
    25.         {
    26.             BoolInt = -1;
    27.         }
    28.        
    29.         else
    30.             BoolInt = 1;
    31.      
    32.  
    33.        for (int i = 0; i < NameAnim.Length; i++)
    34.             {
    35.             if (BoolInt == i)
    36.             {
    37.                 Anim.SetBool(NameAnim[i], true);
    38.             }
    39.             else
    40.                 Anim.SetBool(NameAnim[i], false);
    41.         }
    42.         for (int a = 0; a < Buttons.Length; a++)
    43.         {
    44.             if (Input.GetButton(Buttons[a].name))
    45.             {
    46.                 BoolInt = a;
    47.             }
    48.  
    49.         }
    50.  
    51.  
    52.     }
    53.     }
    54.  
    55.  
    56.  
    57.  
    58.  
    59.