![]() |
Init(args)
Scripting Reference
|
Represents a value of type T that can be assigned through Unity's inspector as well as serialized by its serializer.
If T is a service type then this object represents the shared instance of that service.
If a class derives from Object and implements IValueProvider<T> then Any<T> can wrap an instance of this class and return its IValueProvider<T>.Value when Value is called.
If a class derives from Object and implements IValueByTypeProvider then Any<T> can wrap an instance of this class and use IValueByTypeProvider.TryGetFor to resolve the value to return when Value is called.
T | Type of the value that this object wraps. |
Can be an interface type, a class type or a value type.
Public Member Functions | |
Any (T value) | |
Initializes a new instance of the Any struct with the given underlying value. | |
Any (Object value) | |
Initializes a new instance of the Any struct with the given underlying value. | |
T | GetValue ([DisallowNull] ScriptableObject client, Context context=Context.MainThread) |
Gets the current value of this object. | |
T | GetValue ([AllowNull] Component client, Context context=Context.MainThread) |
Gets the current value of this object. | |
T | GetValueOrDefault ([DisallowNull] object client, Context context=Context.MainThread) |
Gets the value of the current Any<T> object if it has one. | |
async Task< T > | GetValueAsync (Component client=null, Context context=Context.MainThread) |
Gets the value of the current Any<T> object if it has one. | |
bool | GetHasValue ([AllowNull] Component client, Context context=Context.MainThread) |
Gets a value indicating whether the current Any<T> object has a non-null value when retrieved by the client in question in the given context . | |
bool | TryGetValue (out T value) |
Gets the current value of the Any<T> object if it has one. | |
bool | TryGetValue ([AllowNull] Component client, Context context, out T result) |
Gets the value of the current Any<T> object if it has one. | |
bool | TryGetValue (Component client, out T value) |
Gets the value of the current Any<T> object if it has one. | |
override bool | Equals (object obj) |
Determines whether the specified object is equal to the current object. | |
bool | Equals (T other) |
Determines whether the specified object is equal to the value of the current object. | |
bool | Equals (Any< T > other) |
Determines whether the specified object is equal to the current object. | |
bool | Equals (Object other, Context context=Context.MainThread) |
Determines whether the specified object is equal to the value of the current object. | |
override string | ToString () |
Returns a string that represents the underlying object. | |
override int | GetHashCode () |
Returns the hash code for this Any<T> object. | |
Static Public Member Functions | |
static Any< T > | FromValue (T value) |
Creates a new instance of the Any struct with the given underlying value. | |
static Any< T > | FromObject ([AllowNull] Object value) |
Creates a new instance of the Any struct with the given underlying value. | |
static bool | IsCreatableFrom ([AllowNull] Object fromReference, Component forClient) |
Returns a value indicating whether it is possible to create an instance of the Any struct with the underlying value of fromReference . | |
static implicit | operator T (Any< T > instance) |
Defines an implicit conversion of Any<T> to the T object that it wraps. | |
static implicit | operator Any< T > (T value) |
Defines an explicit conversion of T to an Any<T> object. | |
Properties | |
bool | HasValue [get] |
Gets a value indicating whether the current Any<T> object has a non-null underlying type. | |
T | ValueOrDefault [get] |
Gets the value of the current Any<T> object if it has been assigned a valid underlying value; otherwise, the default value of T. | |
T | Value [get] |
Gets the value of the current Any<T> object if it has been assigned a valid underlying value; otherwise, the default value of T. | |