3.1 KiB
uid |
---|
xr-core-utils-capability-profile |
Capability
The Capability system abstracts the current capabilities of the application. A capability is a key-value pair consisting of a string
key and a boolean
value. When not defined, the capability has the Undefined
value. These capabilities can represent input capabilities (such as Controllers or Hands Input), OS permission flags, rendering capability settings (can render particles, text, etc) or any other system capabilities or flags.
Capability Profile
A custom Capability Profile asset
The capability profile is an asset in the project that abstracts the capabilities of a system, such as a device, a platform, an OS or a combination of them. These capabilities can change during authoring or/and runtime.
Note
A capability should only be set to
false
if it's prohibited to be used. If the capability is just unsupported it should have theUndefined
value. For example, if a device has no support for hand tracking, its capability profile should set theHands Input
toUndefined
, rather than explicitlyfalse
. Usually OS or platform (and similar system) capability profiles are the ones that set a capability tofalse
.
Custom Capability Profile
You can create a custom capability profile by inheriting from the CapabilityProfile class (a ScriptableObject) and implementing the interface ICapabilityModifier.
[!code-cscustom_capability_sample]
Note
The CapabilityDictionary is a dictionary to store a set of capabilities, and uses a custom UI drawer to display these capabilities in the Inspector.
Custom Capability
A custom capability key in a CapabilityDictionary
You can add a new capability key by tagging a const string
definition with the CustomCapabilityKey attribute. Custom capability keys tagged with this attribute will showup in the Inspectors of a CapabilityDictionary
. You can specify the order that your custom capability key will be displayed in the context menu by passing an int
value to the attribute constructor, high values are displayed later.
[!code-cscustom_capability_key_sample]
Custom Capability with non Boolean Value
It's possible to define a capability that has a different value type than boolean (for example, a screen width and height maximum size). In this case it's recommended to define an interface as the capability key and query for the values using this interface. The code below has an example for this situation:
[!code-cscustom_capability_type_sample]