Why does this line of code (context below)
if (spellEnum == Spell.Fireball) return "Fire ball";
produce the error:
'Spell' is a type parameter, which is not valid in the given context
public abstract class DataSet : ScriptableObject
{
public abstract string DisplayName<T>(T arg) where T : Enum;
}
public enum Spell { Fireball, Icestorm, MagicMissile };
public class SpellDataSet : DataSet
{
public override string DisplayName<Spell>(Spell spellEnum)
{
if (spellEnum == Spell.Fireball) return "Fire ball";
return "Other spell";
}
}
public class DataLibrary
{
void main()
{
SpellDataSet spellDataSet = new SpellDataSet();
strint test = spellDataSet.DisplayName(Spell.Fireball);
}
}
I want a generic way to access data about various types (spells, items, characters), with data about specific kinds of that type (Spell1, Spell2, etc) accessed via that type's respective enum (Spell), and a universal method (defined in abstract class) across all types will produce the user-friendly name (DisplayName).