Class Parameter of MonoScript throws error on build

I have a public class, PerkClass, which has the parameters: name (String), icon (Texture2D), … and script(MonoScript).

`public class PerkClass{

public var name : String;
public var description : String;
public var icon : Texture2D;
public var pointCost : int;
public var script : MonoScript;
public var id : int;

public var perkType : PerkType;
enum PerkType{Melee, Ranged, Magic, Defense, Favor}

public var rarity : Rarity;
enum Rarity{Common, Uncommon, Rare, Epic}

}`

This compiles fine and I can create an array of PerkClass objects in which I can drag javascripts into the script parameter through the inspector.

However, when I build the project, I get the following error:

26367-forumquestion2.jpg

I have browsed several similar questions but did not find anything useful. I tried changing the parameter type to MonoBehaviour since MonoScript is a polymorph of the MonoBehaviour class, but then I could not drag scripts into the ‘script’ parameter or add them through code.

Any and all help is greatly appreciated!

MonoScript is a Editor class, so you cannot use it at runtime. I’m not sure what you are using this variable for, but the parent class is TextAsset. TextAsset is a runtime class.

Thanks robertbu, mad props! I’m using the variable as a way to quickly reference a script associated with a specific perk and execute it from a GUI where the perk choices will be displayed. I don’t know if this is the best solution but that would be the topic of another question.

Credit goes to robertbu