-
-
Save ArieLeo/7fb9a3d30abb1cc4b53ce39ac54bf45d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using TMPro; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class AnimatorPanel : MonoBehaviour | |
{ | |
[SerializeField] Animator _animator; | |
[SerializeField] Button _button; | |
void Start() | |
{ | |
foreach (var parameter in _animator.parameters) | |
{ | |
if (parameter.type == AnimatorControllerParameterType.Trigger) | |
AddButton(parameter); | |
} | |
} | |
void AddButton(AnimatorControllerParameter parameter) | |
{ | |
var button = Instantiate(_button, transform); | |
foreach(var tmpText in button.GetComponentsInChildren<TMP_Text>()) | |
tmpText.text = parameter.name; | |
button.onClick.AddListener(() => _animator.SetTrigger(parameter.nameHash)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment