SaintsInterface<>SaintsInterface is a simple tool to serialize a UnityEngine.Object (usually your script component) or a serializable struct/class with a required interface.
You can access the interface with the .I field, actual unity object with .V field, and actual serializable class/struct with .VRef field.
TipThis will requires you to use.Ito access the interface. You may want to see Extended Serialization to directly serialize ainterfacetype.
It provides a drawer to let you only select the object that implements the interface.
You can toggle the button at left to toggle either you want an unity instance (object, prefab, scriptableObject etc) or a serializable class/struct.
using SaintsField; [Serializable] private struct NorStructInterface1 : IInterface1 { public int common; public string structString; } [Serializable] private struct NorClassInterface1 : IInterface1 { public int common; public string classString; } public SaintsInterface<IInterface1> myInter1; private void Awake() { Debug.Log(myInter1.I); // the actual interface }
Result of unity object:

Result of serializable class/struct:

This component is inspired by Serialize Interfaces! and Unity3D-SerializableInterface, please go give them a star!
Compared to Serialize Interfaces!, this version has several differences:
- It supports UI Toolkit too.
- Many SaintsField attributes can work together with this one, especially these auto getters, validators etc.