Hi everyone, I’m sorry if this has been asked before but I seared for a long time and couldn’t find an answer to the problem I’m having. I have an interface
public interface IAttackManager
{
int Attack(List<Vector2Int> uList);
}
and implementations of that interface
public class Unit : MonoBehaviour, IAttackManager
{
public abstract int Attack(List<Vector2Int> uList);
}
public class ParticularUnit : Unit
{
public override int Attack(List<Vector2Int> uList)
{
//Do something
}
but when I compile all this in Unity, it says I didn’t implement Attack even though I clearly did. Changing the interface to a generic like this works though for some reason
public interface IAttackManager<T>
{
int Attack(T uList);
}
and implementations of that interface
public class Unit : MonoBehaviour, IAttackManager<List<Vector2Int>>
{
public abstract int Attack(List<Vector2Int> uList);
}
public class ParticularUnit : Unit
{
public override int Attack(List<Vector2Int> uList)
{
//Do something
}
I can’t understand why this fixes the problem and why it wouldn’t work in the other case. Thanks in advance to anyone who can help!