Dropdown值变更触发Animator动画失败求助
Dropdown值变更触发Animator动画失败求助
(编辑于2024年1月6日)
各位大佬好!我最近在做通过TMP_Dropdown切换Animator整数参数的功能,已经按照@ITL的建议调整了代码,但还是没效果。从DebugLog里能看到Dropdown的选中值确实发生了变化,可Animator里对应的整数参数完全没跟着更新,动画自然也触发不了,实在卡在这里了。
下面是我当前的代码:
using UnityEngine.UI; using TMPro; public class AnimINTviaDropdown : MonoBehaviour { public Animator animator; // Reference to the Animator component public int animIndex; // Index of the integer parameter in the Animator private TMP_Dropdown dropdown; // Reference to the TMP_Dropdown component private void Start() { dropdown = GetComponent<TMP_Dropdown>(); // Get the reference to the TMP_Dropdown component dropdown.onValueChanged.AddListener(OnDropdownValueChanged); // Subscribe to the value changed event } private void OnDropdownValueChanged(int selectedValue) { // Set the integer parameter value in the Animator animator.SetInteger(animIndex, selectedValue); } }
有没有大佬能帮我排查下问题所在?
备注:内容来源于stack exchange,提问作者joe pie
相关产品推荐
相关产品推荐

