04. IValueProvider<T>

  05. Reference No Comments

Represents an object that can provide a value of type T on demand.

The value of a UnityEngine.Object-derived class that implements IValueProvider<T> can be assigned to an Init argument field of type T. When this is done, the value returned by the provider at runtime will be passed to the client during initialization.

This can enable patterns such as:

  • ScriptableObject asset that provides a reference to a singleton instance which is only created at runtime.
  • ScriptableObject asset that provides a dynamic primitive value such as an int that increments every second.
  • A component that provides a dynamic primitive value such as a float that equals the distance between the Player GameObject and the GameObject that holds the component in question.
  • ScriptableObject asset that returns a random position.

Leave a Reply

Your email address will not be published. Required fields are marked *