- Home /
Inspector problem with Non-Monobehaviour Classes
Hey,
Is there a way to drag and drop a Class which inherits from a Base Class (The base class implements an Interface ) to a Monobehaviour Class?.
public class TowerButton : MonoBehaviour {
public UI2DSprite LogoTower;
public UILabel lblCost;
public ITower tower;
...
...
Because there are many different Towers ( all inherits ITower ) I want just drag and drop a Script ( Non-Monobehaviour ) to the Inspector in ITower tower of TowerButton class.
Is there a way? ( The class which not inherits from Non-Monobehaviour is Serializable)
Thanks in advance.
There is no way of doing this, specifically because non $$anonymous$$onoBehaviour
classes are not part of the Unity object management system.
Answer by Paulius-Liekis · Mar 02, 2014 at 11:07 AM
No, you can not.
BTW.: you're saying saying "can I assign type X to a reference Y" instead of "can I assign an object of type X to reference Y", which makes less sense.
Anyway, you could write some custom inspector which would allow you to assign type/object and then fill data.
Your answer
Follow this Question
Related Questions
Starting with UNITY. what first? 1 Answer
Interface 3D 1 Answer
Problems with GUI 0 Answers
Exposing interface implementation 3 Answers
Simple menu 1 Answer