CS0311 no implicit reference conversion between two inheriting generics #6455
-
gameObject.AddComponent<Renderer>(); I'm getting this error for the line above
This is the extension method public static T AddComponent<T>(this IGameObject gameObject) where T : IComponent<IGameObject>, new() This is the public sealed class Renderer : Component<GameObject>, IHasExtents ...which inherits public abstract class Component<T> : GameComponent, IComponent<T> where T : IGameObject As you can see, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It's a question of variance. |
Beta Was this translation helpful? Give feedback.
It's a question of variance.
Component<GameObject>
is a subtype ofIComponent<GameObject>
, butIComponent<GameObject>
is not a subtype ofIComponent<IGameObject>
.