网站排名seo培训,久久建设集团有限公司,网站修改标题有影响吗,十大团购网站感觉Unity中InputAction的使用#xff0c;步步都是坑。
需求点介绍
当用户长按0.5s 键盘X或者VR left controller primaryButton (即X键)时#xff0c;显示下一个图片。
步骤总览
创建InputAction资产将该InputAction资产绑定到某个GameObject上在对应的script中#xf…感觉Unity中InputAction的使用步步都是坑。
需求点介绍
当用户长按0.5s 键盘X或者VR left controller primaryButton (即X键)时显示下一个图片。
步骤总览
创建InputAction资产将该InputAction资产绑定到某个GameObject上在对应的script中接收InputAction触发的事件完成“显示下一个图片”的逻辑
细节 创建InputAction资产 将该InputAction资产绑定到某个GameObject上。
如果Behaviour是send messages或者broadcast messages那这个GameObject或者其子GameObject包含Component这个Component有需要检测InputAction输入的function。
如果Behaviour是Invoke Unity Event那好像绑定在哪个GameObject都没有关系只要Player Input这个component能在function之前被初始化就行。
至于Behavior如何设置见官网 不过官网说得也不明不白的。 在我的例子中我需要设置成Invoke Unity Events然后像对待UI控件一样显性绑定才能触发function的运行。Send/Broadcast Messages都不行。 在对应的script中接收InputAction触发的事件完成“显示下一个图片”的逻辑 public void ChangeStrokeImage(InputAction.CallbackContext context){ if (context.action.name DrawNext) {if (context.performed) // Otherwise this will be triggered three times. {if (textures ! null textures.Length 0){currentIndex currentIndex % textures.Length;strokeRawImage.texture textures[currentIndex];currentIndex currentIndex 1;}}}}