Class ApiLayersFeature
Provides comprehensive OpenXR API layer support for debugging and development. This feature manages the runtime configuration of OpenXR API layers, handles platform environment setup, integrates with debug utilities, and invokes API layer support interface objects.
Inherited Members
Namespace: UnityEngine.XR.OpenXR.Features
Assembly: Unity.XR.OpenXR.dll
Syntax
public class ApiLayersFeature : OpenXRFeature
Remarks
Enable this feature in your OpenXR settings to activate API layer support in your application. The ApiLayersFeature manages the lifecycle of API layers, configuring them before the OpenXR instance is created and cleaning them up on instance destruction. It also provides a registration system for ISupport implementations that need to perform custom setup and teardown operations. API layers execute in the order they appear in the collection.
Examples
This example demonstrates how to programmatically access and configure API layers at runtime:
OpenXRSettings settings = OpenXRSettings.GetSettingsForBuildTargetGroup(BuildTargetGroup.Standalone);
ApiLayersFeature apiLayersFeature = settings.GetFeature<ApiLayersFeature>();
if (apiLayersFeature != null && apiLayersFeature.enabled)
{
// Enable core validation layer for x64 architecture
apiLayersFeature.apiLayers.SetEnabled("XR_APILAYER_LUNARG_core_validation", Architecture.X64, true);
Debug.Log($"API layers configured: {apiLayersFeature.apiLayers.collection.Count} layers available");
}
Fields
featureId
A unique identifier for this feature.
Declaration
public const string featureId = "com.unity.openxr.feature.apilayers"
Field Value
| Type | Description |
|---|---|
| string |
See Also
Properties
apiLayers
Gets the API layers instance for this feature configuration.
Declaration
public ApiLayers apiLayers { get; }
Property Value
| Type | Description |
|---|---|
| ApiLayers |
See Also
Methods
AddSupport(ISupport)
Registration method for support objects.
Declaration
public static void AddSupport(ApiLayers.ISupport support)
Parameters
| Type | Name | Description |
|---|---|---|
| ApiLayers.ISupport | support | The support object to add. |
See Also
GetValidationChecks(List<ValidationRule>, BuildTargetGroup)
Allows a feature to add to a list of validation rules which your feature will evaluate at build time. Details of the validation results can be found in OpenXRProjectValidation.
Declaration
protected override void GetValidationChecks(List<OpenXRFeature.ValidationRule> rules, BuildTargetGroup targetGroup)
Parameters
| Type | Name | Description |
|---|---|---|
| List<OpenXRFeature.ValidationRule> | rules | Your feature will check the rules in this list at build time. Add rules that you want your feature to check, and remove rules that you want your feature to ignore. |
| BuildTargetGroup | targetGroup | Build target group these validation rules will be evaluated for. |
Overrides
See Also
HookGetInstanceProcAddr(IntPtr)
Hooks into the OpenXR instance creation process to configure API layers and the environment. This method is called before the OpenXR instance is created.
Declaration
protected override IntPtr HookGetInstanceProcAddr(IntPtr hookGetInstanceProcAddr)
Parameters
| Type | Name | Description |
|---|---|---|
| IntPtr | hookGetInstanceProcAddr | The original GetInstanceProcAddr function pointer. |
Returns
| Type | Description |
|---|---|
| IntPtr | The original function pointer. |
Overrides
See Also
OnInstanceCreate(ulong)
Called after the OpenXR instance is successfully created.
Declaration
protected override bool OnInstanceCreate(ulong xrInstance)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | xrInstance | The handle to the created OpenXR instance. |
Returns
| Type | Description |
|---|---|
| bool | True if initialization was successful, false otherwise. |
Overrides
See Also
OnInstanceDestroy(ulong)
Called when the OpenXR instance is being destroyed. This method triggers the teardown process for all support classes.
Declaration
protected override void OnInstanceDestroy(ulong xrInstance)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | xrInstance | The handle of the OpenXR instance being destroyed. |
Overrides
See Also
RemoveSupport(ISupport)
De-registration method for support objects.
Declaration
public static void RemoveSupport(ApiLayers.ISupport support)
Parameters
| Type | Name | Description |
|---|---|---|
| ApiLayers.ISupport | support | The support object to remove. |