unity的新输入系统——泛型参数透传

unity's new input system - generic parameter passthrough

我正在为 Unity 的新输入系统编写半通用包装器。

using UnityEngine.InputSystem;
    
public class NewInputSystemWrapper
{
  public void test<T>() where T : notnull
  {
    InputAction action = Whatever();
    _ = action.ReadValue<T>();
  }
}

我收到以下错误消息。但为什么?我已经声明 T 不为空。 (我只想通过 T 传递给 ReadValue 方法。)

只需要遵循ReadValue方法的约束即可。

public void test<T>() where T : struct