I need to link class of a kind in unity, using the drag-and-drop of unity. For this I created an interface to accept more than one class. Making the code stay that way:
In the line 8, I declare the variable for accept StatesInterface.
But not appears in the Unity.
Unity doesn’t serialize variables that reference C# interfaces.
You could declare the variable as a MonoBehaviour and add a property that casts it as StatesInterface:
public class TextController : MonoBehaviour {
public Text text;
public MonoBehaviour states;
public StatesInterface statesInterface { get { return states as StatesInterface; } }
...
}
If you want to validate that the drag-and-drop is a valid StatesInterface, you can write a custom property drawer for that variable.