Hey! Glad to hear it works great for you!
1. Pretty safe. On the runtime level, itās standard C#, so nothing special there. As for the Editor level, it uses the Legacy GUI, which might get deprecated one day, although not soon. Iām currently looking at changing the code to use UI Toolkit, but the whole thing changes too much to be the reliable solution for now.
2. Weāve been using SerializableInterface in multiple projects since last year, mostly in VR (Android), with IL2CPP backend, without any issues. Since IL2CPP is the most restrictive backend, it should work very well in Mono. (we do use it in Mono when we test our application, cuz itās faster to build). We also tested it in WebGL. Again, thereās nothing special about the code, it just wraps an interface, thereās no reflection or weird code there, so it should work on all platforms.
- Didnāt test yet. Would be nice to do so if anyone is a benchmark genius. But yes it does - of course - since itās not just a simple reference to an interface, but a wrapper class. The trade-off though is ABSOLUTLY worth it. Weāve been doing the best architecture design since weāve introduced it in our projects. I mean, just about everything is reusable now. Itās insane. But! Since you asked, these are the two considerations weāve had in terms of performance:
3.1 Serialization:
It does have some serialization impacts, although, itās not a lot. Basically, SerializableInterface has 3 fields, which all of them needs to be serialized (in the scene, prefab or in a ScriptableObjectā¦). So while you only deal with an interface, SerializableInterface needs to have a Mode (enum), a UnityReference (Object) and a RawObjectReference (object). This can slightly increase the size of your serialized Object, but it ensures a proper serialization of Unity Objects and raw C# objects (for the null check, for instance).
3.2 Allocation:
While an interface field can contain a struct and be allocated on the stack or directly in an object on the heap, SerializableInterface is a class, so it will be declared on the heap and subject to GC. This shouldnāt be a huge deal in most cases though. In any case, changing SerializableInterface to a struct wasnāt a practical choice for us since we inherit from it.
Hope it answers your questions.