Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- using MoreMountains.TopDownEngine;
- /// <summary>
- /// Checks the _animator for any Trigger parameters, then creates buttons that trigger each in UI
- /// Add this script to a UI object with a Layout component.
- /// </summary>
- public class AnimationShowcase : MonoBehaviour
- {
- [SerializeField] private Animator _animator;
- [SerializeField] private Button _buttonPrefab;
- private void AddButton(AnimatorControllerParameter parameter)
- {
- //create a new button
- var button = Instantiate(_buttonPrefab,transform);
- //Set the button text to the trigger name
- foreach (var tmpText in button.GetComponentsInChildren<TMP_Text>())
- {
- tmpText.text = parameter.name;
- //set the button's click behaviour
- // this is the problem i'm trying to set the bool to either true or false based on its current value
- // i think the right word is a flip flop
- button.onClick.AddListener(()=> parameter != parameter);
- }
- }
- public void SetAnimatorOnAnimShowcase(Animator animator)
- {
- _animator = animator;
- Debug.Log("animator set");
- //Find all parameters in the Animator
- foreach (var parameter in _animator.parameters)
- {
- //if it's a Trigger, create a button for it
- if(parameter.type == AnimatorControllerParameterType.Bool)
- {
- Debug.Log(parameter);
- AddButton(parameter);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement