Skip to content
One Last Click Docs

Usage

Given the interface:

public interface IPlayerCueInputProvider
{
void DoSomething();
}

You can implement on any UnityEngine.Object type:

public class InputProvider : MonoBehaviour, IPlayerCueInputProvider
{
void DoSomething();
}

or

public class ScriptableInputProvider : ScriptableObject, IPlayerCueInputProvider
{
void DoSomething();
}

Then serialize private interfaces on any other type:

[SerializeField] IPlayerCueInputProvider _inputProvider;

The field can then be used normally:

_inputProvider.DoSomething();

Direct interface fields support:

  • Scene MonoBehaviour instances.
  • ScriptableObject assets.
  • Any UnityEngine.Object that implements the target interface.
  • GameObject references — the drawer automatically finds a matching component.

Inspector view of an interface field

The Custom Property Drawer will:

  • Display the resolved object type.
  • Warn when the assigned object does not implement or inherit from the required type.

Drag and drop any MonoBehaviour or ScriptableObject instance onto the field to set the value.

If you drag a GameObject, it will try to find a component on the GameObject that implements the interface

UnityObjectReference<T> is also available when you want an explicit serializable wrapper around the reference:

[SerializeField] UnityObjectReference<IPlayerCueInputProvider> _inputProvider;

Access the referenced object through .Value, or use the implicit conversion:

_inputProvider.Value.DoSomething();
IPlayerCueInputProvider input = _inputProvider;

For most use cases, however, the direct interface syntax is the recommended approach:

[SerializeField] IPlayerCueInputProvider _inputProvider;