Unity开发Cosmos使用BNG Framework获取按键信息
1、新建一个脚本,复制下面代码
using BNG;
[Header("Input")]//[Tooltip("The key(s) to use to toggle locomotion type")]public List<ControllerBinding> locomotionToggleInput = new List<ControllerBinding>() { ControllerBinding.YButtonDown };bool actionToggle = false;void Update(){// Make sure we don't double toggle our inputsif (!actionToggle){CheckControllerToggleInput();}actionToggle = false;}public virtual void CheckControllerToggleInput(){// Check for bound controller buttonfor (int x = 0; x < locomotionToggleInput.Count; x++){if (InputBridge.Instance.GetControllerBindingValue(locomotionToggleInput[x])){Debug.Log("111111111");}}}
2、挂载在场景任意物体上
可以切换任意手柄按钮