- Home /
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:
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!
$$anonymous$$onoScript 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.
re: 'this is a test': Approval of question can take $$anonymous$$utes or hours depending on who is active on the list and the quality of your question. Once you have 15 $$anonymous$$arma points (earned by accepting 2 answers, giving 2 good comments, or having 1 answer accepted), your questions will no longer go through moderation.
Answer by spookymoose · May 09, 2014 at 03:13 AM
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
Your answer
