How to make a button control Animator animation
I have a script that works with a mousedown and with a keydown, but I cant get a button to activate my animation in Animator.
In Animator, I have set up animations with transitions. I set a bool parameter called "ButtonSelect". My expectation is the when I select the button "CliquezMoi" it will toggle the "ButtonSelect" bool. This works with mousedown, but I cant seem to set up a UI button the way Unity wants.
using UnityEngine;
using System.Collections;
public class CliquezVous : MonoBehaviour
{
public Animator anim;
private bool ButtonSelect;
// Use this for initialization
void Start()
{
anim = GetComponent<Animator>();
ButtonSelect = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("CliquezMoi"))
{
if (ButtonSelect == true)
{
ButtonSelect = false;
}
else
{
ButtonSelect = true;
}
}
anim.SetBool("ButtonSelect", ButtonSelect);
}
}
Your answer
Follow this Question
Related Questions
How would i modify my current script to remove these UI buttons without killing my pause menu? 1 Answer
C sharp script, to open a Unity standalone .exe file on a network drive 0 Answers
How do I make GUI to appear on a game object instead of rendering it on screen? 1 Answer
how do i take whats on one UI canvas and make it apear on another in real time(for a card game) 0 Answers
How to keep program linear and synchronous while getting user input? 1 Answer