Struct Property
Struct of this type store a property value and its current type.
Namespace: UnityEngine.GameFoundation
Syntax
[Serializable]
public struct Property : IEquatable<Property>, IEqualityComparer<Property>, IComparable<Property>
Remarks
All fields should be declared in this script to avoid the compilation warning CS0282 (see https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0282).
Properties
type
Stored value's type.
Declaration
public PropertyType type { get; }
Property Value
Type | Description |
---|---|
PropertyType |
Methods
AsAddressable<T>()
Explicitly returns this Property as an Addressables handle.
Declaration
public AsyncOperationHandle<T> AsAddressable<T>()
Returns
Type | Description |
---|---|
AsyncOperationHandle<T> | Async-operation handle to this Addressable. Addressables will be loaded asynchronously, and the returned handle can be used to check status of async load and retrieve requested Addressables asset when it's ready. |
Type Parameters
Name | Description |
---|---|
T | Type of Addressables asset to return. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsAddressables<T>(Action<T>)
Explicitly returns this Property as an Addressables handle to list of assets.
Declaration
public AsyncOperationHandle<IList<T>> AsAddressables<T>(Action<T> callback = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T> | callback | Callback Action<T> that is called per load operation. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<IList<T>> | Async-operation handle to this Addressable. Addressables will be loaded asynchronously, and the returned handle can be used to check status of async load and retrieve requested Addressables asset when it's ready. Important: whereas AsAddressable<T>() returns a single asset, this returns a list of matching assets so it will be necessary to extract the needed asset from the list. By using the filter, you can restrict the call to just a single asset so it can easily be extracted. |
Type Parameters
Name | Description |
---|---|
T | Type of Addressables asset list to return. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsAddressables<T>(String, Addressables.MergeMode, Action<T>)
Explicitly returns this Property as an Addressables handle allowing a string to be used to filter, usually by Addressables label.
Declaration
public AsyncOperationHandle<IList<T>> AsAddressables<T>(string label, Addressables.MergeMode mergeMode = Addressables.MergeMode.Intersection, Action<T> callback = null)
Parameters
Type | Name | Description |
---|---|---|
String | label | Label to use in filtering. By default, method uses Addressable Intersection to further restrict the output (for example based on a label specified to choose between different assets of the same Address). |
Addressables.MergeMode | mergeMode | Desired merge for labels and Game Foundation Addressables address. Defaults to Intersection to permit finding a specific asset with specified label, but any valid Addressables.MergeMode enum value can be used. |
Action<T> | callback | Callback Action<T> that is called per load operation. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<IList<T>> | Async-operation handle to this Addressable. Addressables will be loaded asynchronously, and the returned handle can be used to check status of async load and retrieve requested Addressables asset list when it's ready. Important: whereas AsAddressable<T>() returns a single asset, this returns a list of matching assets so it will be necessary to extract the needed asset from the list. By using the filter, you can restrict the call to just a single asset so it can easily be extracted. |
Type Parameters
Name | Description |
---|---|
T | Type of Addressables asset list to return. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsAddressString()
Explicitly returns this Property as an address for use with Addressables.
Declaration
public string AsAddressString()
Returns
Type | Description |
---|---|
String | This Addressables Property's address as a string. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsAsset<TAsset>()
Explicitly casts this Property into
an asset of the given TAsset
.
Declaration
public TAsset AsAsset<TAsset>()
where TAsset : Object
Returns
Type | Description |
---|---|
TAsset | The asset reference. |
Type Parameters
Name | Description |
---|---|
TAsset | The type of the returned asset. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsBool()
Explicitly casts this Property into a bool. Handle convertible types properly.
Declaration
public bool AsBool()
Returns
Type | Description |
---|---|
Boolean | The Boolean value. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsDouble()
Explicitly casts this Property into a double. Handle convertible types properly.
Declaration
public double AsDouble()
Returns
Type | Description |
---|---|
Double | The Double value. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsFloat()
Explicitly casts this Property into a float. Handle convertible types properly.
Declaration
public float AsFloat()
Returns
Type | Description |
---|---|
Single | The Single value. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
AsInt()
Explicitly casts this Property into an integer. Handle convertible types properly.
Declaration
public int AsInt()
Returns
Type | Description |
---|---|
Int32 | The Int32 value. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
OverflowException | Thrown if the stored value is outside int boundaries. |
AsLong()
Explicitly casts this Property into a long. Handle convertible types properly.
Declaration
public long AsLong()
Returns
Type | Description |
---|---|
Int64 | The Int64 value. |
Exceptions
Type | Condition |
---|---|
InvalidCastException | Thrown if the stored type isn't compatible with the requested type. |
OverflowException | Thrown if the stored value is outside long boundaries. |
AsString()
Explicitly casts this Property into a string. Handle convertible types properly.
Declaration
public string AsString()
Returns
Type | Description |
---|---|
String | The String value. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if the stored type isn't supported. |
CompareTo(Property)
Declaration
public int CompareTo(Property other)
Parameters
Type | Name | Description |
---|---|---|
Property | other |
Returns
Type | Description |
---|---|
Int32 |
CreateAddressablesProperty(String)
Create a Property of type Addressables
using the given address
.
Note that the given address
isn't verified--editor or runtime code must ensure
specified address exists and is of valid type.
Declaration
public static Property CreateAddressablesProperty(string address)
Parameters
Type | Name | Description |
---|---|---|
String | address | The address of desired Addressables asset. |
Returns
Type | Description |
---|---|
Property | Return the created property. |
CreateAssetProperty(String)
Create a Property of type ResourcesAsset
using the given path
.
Note that the given path
isn't verified.
Declaration
public static Property CreateAssetProperty(string path)
Parameters
Type | Name | Description |
---|---|---|
String | path | A path to an asset from the Resources folder. |
Returns
Type | Description |
---|---|
Property | Return the created property. |
Equals(Object)
Tells whether this Property instance equals obj
.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The other object to compare this instance with. |
Returns
Type | Description |
---|---|
Boolean |
|
Overrides
Equals(Property)
Declaration
public bool Equals(Property other)
Parameters
Type | Name | Description |
---|---|---|
Property | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Property, Property)
Declaration
public bool Equals(Property x, Property y)
Parameters
Type | Name | Description |
---|---|---|
Property | x | |
Property | y |
Returns
Type | Description |
---|---|
Boolean |
GetHashCode()
Gets the hash code of this Property instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code of this Property instance. |
Overrides
GetHashCode(Property)
Declaration
public int GetHashCode(Property obj)
Parameters
Type | Name | Description |
---|---|---|
Property | obj |
Returns
Type | Description |
---|---|
Int32 |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
TryParse(String, String, out Property)
Create a new Property instance by parsing the given
rawPropertyType
and rawValue
.
Declaration
public static bool TryParse(string rawPropertyType, string rawValue, out Property property)
Parameters
Type | Name | Description |
---|---|---|
String | rawPropertyType | Property type to parse. |
String | rawValue | Property value to parse. |
Property | property | Created Property if the parsing was successful. |
Returns
Type | Description |
---|---|
Boolean | Return true if the given strings could be parsed into a valid Property; return false otherwise. |
Operators
Addition(Property, Property)
Add the two given operands into a new Property.
Declaration
public static Property operator +(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Property | A new Property resulting from the addition of both operands. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if one of the operands' type isn't supported. |
Equality(Property, Property)
Compare the two given operands for equality.
Declaration
public static bool operator ==(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Boolean | True if both operands have the same property type and value. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if the stored type isn't supported. |
GreaterThan(Property, Property)
Compare the two given operands if they are numbers.
Declaration
public static bool operator>(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Boolean | True if |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if one of the operands' type isn't supported. |
GreaterThanOrEqual(Property, Property)
Compare the two given operands if they are numbers.
Declaration
public static bool operator >=(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Boolean | True if |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if one of the operands' type isn't supported. |
Implicit(Boolean to Property)
Construct a Property from the given value
.
Declaration
public static implicit operator Property(bool value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | value | The value to cast into Property. |
Returns
Type | Description |
---|---|
Property | The |
Implicit(Double to Property)
Construct a Property from the given value
.
Declaration
public static implicit operator Property(double value)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The value to cast into Property. |
Returns
Type | Description |
---|---|
Property | The |
Implicit(Int32 to Property)
Construct a Property from the given value
.
Declaration
public static implicit operator Property(int value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | The value to cast into Property. |
Returns
Type | Description |
---|---|
Property | The |
Implicit(Int64 to Property)
Construct a Property from the given value
.
Declaration
public static implicit operator Property(long value)
Parameters
Type | Name | Description |
---|---|---|
Int64 | value | The value to cast into Property. |
Returns
Type | Description |
---|---|
Property | The |
Implicit(Single to Property)
Construct a Property from the given value
.
Declaration
public static implicit operator Property(float value)
Parameters
Type | Name | Description |
---|---|---|
Single | value | The value to cast into Property. |
Returns
Type | Description |
---|---|
Property | The |
Implicit(String to Property)
Construct a Property from the given value
.
Declaration
public static implicit operator Property(string value)
Parameters
Type | Name | Description |
---|---|---|
String | value | The value to cast into Property. |
Returns
Type | Description |
---|---|
Property | The |
Implicit(Property to Boolean)
Declaration
public static implicit operator bool (Property value)
Parameters
Type | Name | Description |
---|---|---|
Property | value | The value to cast. |
Returns
Type | Description |
---|---|
Boolean | The Boolean value of the property. |
Implicit(Property to Double)
Declaration
public static implicit operator double (Property value)
Parameters
Type | Name | Description |
---|---|---|
Property | value | The value to cast. |
Returns
Type | Description |
---|---|
Double | The Double value of the property. |
Implicit(Property to Int32)
Declaration
public static implicit operator int (Property value)
Parameters
Type | Name | Description |
---|---|---|
Property | value | The value to cast. |
Returns
Type | Description |
---|---|
Int32 | The Int32 value of the property. |
Implicit(Property to Int64)
Declaration
public static implicit operator long (Property value)
Parameters
Type | Name | Description |
---|---|---|
Property | value | The value to cast. |
Returns
Type | Description |
---|---|
Int64 | The Int64 value of the property. |
Implicit(Property to Single)
Declaration
public static implicit operator float (Property value)
Parameters
Type | Name | Description |
---|---|---|
Property | value | The value to cast. |
Returns
Type | Description |
---|---|
Single | The Single value of the property. |
Implicit(Property to String)
Declaration
public static implicit operator string (Property value)
Parameters
Type | Name | Description |
---|---|---|
Property | value | The value to cast. |
Returns
Type | Description |
---|---|
String | The String value. |
Inequality(Property, Property)
Compare the two given operands for inequality.
Declaration
public static bool operator !=(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Boolean | True if both operands have different property type or value. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if the stored type isn't supported. |
LessThan(Property, Property)
Compare the two given operands if they are numbers.
Declaration
public static bool operator <(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Boolean | True if |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if one of the operands' type isn't supported. |
LessThanOrEqual(Property, Property)
Compare the two given operands if they are numbers.
Declaration
public static bool operator <=(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Boolean | True if |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if one of the operands' type isn't supported. |
Subtraction(Property, Property)
Subtract the two given operands into a new Property.
Declaration
public static Property operator -(Property a, Property b)
Parameters
Type | Name | Description |
---|---|---|
Property | a | Left operand. |
Property | b | Right operand. |
Returns
Type | Description |
---|---|
Property | A new Property resulting from the subtraction of both operands. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if one of the operands' type isn't supported. |