Home > other >  unity's new input system - generic parameter passthrough
unity's new input system - generic parameter passthrough

Time:04-17

I am writing an semi generic wrapper for unity's new input system.

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

I am getting the following error message. But why? I have declared that T is notnull. (I just want to pass through T to the ReadValue method.) enter image description here

CodePudding user response:

Just follow the constraint of ReadValue method.

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