✅ Pass in arguments to a generic constructor

    public T AddComponent<T>() where T: Component, new() {
        Component component = new T(this);
        return (T)AddComponent(component);
    }

i want to be able to create new instances of T in the method, but i get the error 'T': cannot provide arguments when creating an instance of a variable type. how can i make this work? one precondition is that all child of Component will only have one argument in their constructor
Was this page helpful?