Interface support in the Editor

I’m new to Unity and I just realized that interface properties don’t show in the UI.

For instance if I want to assign any enemy which inherits IAgro I’d do something like this:

public class MyObject : MonoBehavior {
public IAgro object;
}

But property “object” won’t display in the Editor. I realize this is a limitation, but does anyone have a workaround? Or what’s the alternative so I don’t have to create a bunch of repeat code?

Its because we dont know how to serialise an interface. Only objects we can serialise will appear in the inspector.
You could do it manually like this (SOLUTION) How to serialize interfaces, generics, auto-properties and abstract System.Object classes? - Questions & Answers - Unity Discussions

Also look at scriptable objects although this wont work for interfaces, it will allow for serialising polymorphic data types.

Can you elaborate a little bit?

https://blogs.unity3d.com/2014/06/24/serialization-in-unity/

I still don’t understand why you can’t serialize the actual object that implements the interface.