Show variable of class that dont inherit from MonoBehaviour in Inspector
Lets say I have 2 scripts, Person:
public class Person {
public int height, weight;
public Person(int h, int w){
height = h; weigth = w;
}
}
and Warrior:
public class Warrior : Person {
void Start(){
weight = 100;
height = 200;
}
void Update(){
weight++;
height++;
}
}
Given I associated the script Warrior to a GameObject, I won't be able to see the public variables of Warrior because it do not inherit from MonoBehaviour.
My question is: how do I do to show the variables information at Inspector, with a script that do not inherit from MonoBehaviour?
Answer by Firedan1176 · Feb 05, 2016 at 05:03 PM
Above your class that does not inherit from MonoBehaviour (Player), you should add [System.Serializable]
, which will make it appear.
Your answer
Follow this Question
Related Questions
Inheriting from a class that inherits from monobehaviour 3 Answers
Custom Editor List with child classes 1 Answer
Building a Collection of Subclasses and Modifying Their Public Members from the Inspector 1 Answer
How to inherit from a class that inherits from MonoBehaviour 1 Answer
Inheriting from a class that inherits from monobehaviour, from inspector 0 Answers