Unity-InControl如何检测一次Action推送?

时间:2019-04-22 20:32:28

标签: c# unity3d assets

我对Unity插件的用户输入有疑问。我正在使用InControl并进行了所有设置。我正在测试,当我按住一个动作按钮(A,B,X,Y或十字形,方形,三角形,圆形)时,仅应在按下该按钮后才打印。除了它循环打印消息。我可以弄清楚是否有一种方法可以查看是否松开了“操作”按钮,但是在源代码或联机中绝对没有任何内容可以放开或按住按钮。有帮助吗?

在线搜索,甚至浏览了InControl脚本,都找不到与按住或放开按钮有关的任何方法。

InputDevice controller1;

void Start ()
{
  controller1 = InputManager.Devices[0]; //or InputManager.ActiveDevice
}

void Update ()
{
  if (controller1.Action1)
  {
    Debug.Log("Controller button A pressed");
    //constantly loops this Log instead of only executing once
  }
}

如果您按住“操作”按钮,则日志仅应打印一次。

1 个答案:

答案 0 :(得分:0)

您好,请参阅此InControl文档:

http://www.gallantgames.com/pages/incontrol-getting-started

如果您向下滚动页面,您将看到以下列表:

control.IsPressed;   // bool, is currently pressed

control.WasPressed;  // bool, pressed since previous tick

control.WasReleased; // bool, released since previous tick

control.HasChanged;  // bool, has changed since previous tick

control.State;       // bool, is currently pressed (same as IsPressed)

control.Value;       // float, in range -1..1 for axes, 0..1 for buttons / triggers

control.LastState;   // bool, previous tick state

control.LastValue;   // float, previous tick value

这有助于加油。