Inheriting from a class that inherits from monobehaviour, from inspector
Hello,
I wish to make a card system, with basic classes like
public class Card : MonoBehaviour
{
public string name;
[...]
}
public class AttackCard : Card
{
public int attackPower;
[...]
}
public class DefenseCard : Card
{
public int defensePower;
[...]
}
The problem I have now is that I don't manage to add an AttackCard component from the inspector. The only ways I know is to drag a script or click "Add Component", and in both cases I can only add a whole script, with no choice but to use the class Card.
One solution would (I guess) be to have one script per class type, but this looks really ugly. Another solution would be to create the component at runtime using another script, but this makes some essentially useless code, and (among other issues) prevents from using the inspector to change parameters.
Does someone know if a better solution exists?
(I found this related topic https://answers.unity.com/questions/119516/inheriting-from-a-class-that-inherits-from-monobeh.html?_ga=2.17989375.773754909.1597942728-1808732535.1595070822, but it does not answer)