05. Any<T>

  03. Features No Comments

The Any<T> struct is similar to the Initializer class, but instead of it allowing you to specify all the Init arguments for a client, the Any<T> struct lets you specify just one argument.

For example, if you wanted to make it possible to assign any class that implements the IPlayer interface using the inspector, you could use the following syntax:

[SerializeField]
Any<IPlayer> player;

To get the value that was assigned to the Any struct simply call the Value property on it.

player.Value.MoveTo(position);

Similar to the Initializer class, Any<T> also supports automatically retrieving service instances at runtime.

Leave a Reply

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