Prefab Custom Scripts

Trying to do a Card Game. I have a card wich has and Element class as a parameter…

Class Card {
   public int atack;
   public Element el;
}

Class Element{
 public string name;
 public int defense;
}

When i add the Card script to my prefab card I can edit my atack and can select my element… the problem is: when i try to add this element i have no elements… since its a class i created.

How can i instantiate this elements so i can use them?

Why don’t you add a constructor to the Element class and then initialize the el in the Card class? What I mean is in Element class,

public Element(string name, int defense){
   this.name = name;
   this.defense = defense;
}

and then initialize it in the Card class by code like so:

el = new Element(name, defense);

By the way, you cannot use ‘name’ as a variable. Unity already uses it. Name it something else like ‘displayName’ or something.