首页 > 解决方案 > 无法将类型 bool 隐式转换为 unity Engine Animator PlayerPrefs

问题描述

cannot implicitly convert  type bool  to unity Engine Animator

所以我正在尝试使用播放器预制件制作我的动画之一,但我不断收到此错误

shopm.light1 = PlayerPrefs.GetInt("animation") == 2;

我也尝试过这样做,但我收到了相同的错误消息

shopm.light1 = PlayerPrefs.GetInt("animation", shopm.light1 ? 1 : 0);

标签: c#unity3d

解决方案


您需要提供更多数据才能获得完整的答案,但根据您的代码,我假设shopm是一个动画师,而light1是一个参数,所以检查一下,看看它是否有帮助:

shopm.SetBool("light1", PlayerPrefs.GetInt("animation") == 2);

推荐阅读