using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using UnityEngine; using UnityEngine.Bindings; using UnityEngine.Rendering; using UnityEngine.Scripting; [assembly: InternalsVisibleTo("UnityEngine.UIElementsModule")] [assembly: InternalsVisibleTo("UnityEngine.UIElementsNativeModule")] [assembly: InternalsVisibleTo("UnityEngine.UIModule")] [assembly: InternalsVisibleTo("UnityEngine.TilemapModule")] [assembly: InternalsVisibleTo("UnityEngine.TextCoreTextEngineModule")] [assembly: InternalsVisibleTo("UnityEngine.TextCoreFontEngineModule")] [assembly: InternalsVisibleTo("UnityEngine.TerrainPhysicsModule")] [assembly: InternalsVisibleTo("UnityEngine.SubstanceModule")] [assembly: InternalsVisibleTo("UnityEngine.SubsystemsModule")] [assembly: InternalsVisibleTo("UnityEngine.UmbraModule")] [assembly: InternalsVisibleTo("UnityEngine.StreamingModule")] [assembly: InternalsVisibleTo("UnityEngine.SpriteShapeModule")] [assembly: InternalsVisibleTo("UnityEngine.SpriteMaskModule")] [assembly: InternalsVisibleTo("UnityEngine.ScreenCaptureModule")] [assembly: InternalsVisibleTo("UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule")] [assembly: InternalsVisibleTo("UnityEngine.TerrainModule")] [assembly: InternalsVisibleTo("UnityEngine.UNETModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityCurlModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityTestProtocolModule")] [assembly: InternalsVisibleTo("UnityEngine.PS5VRModule")] [assembly: InternalsVisibleTo("UnityEngine.PS5Module")] [assembly: InternalsVisibleTo("UnityEngine.PS4VRModule")] [assembly: InternalsVisibleTo("UnityEngine.PS4Module")] [assembly: InternalsVisibleTo("UnityEngine.XboxOneModule")] [assembly: InternalsVisibleTo("UnityEngine.SwitchModule")] [assembly: InternalsVisibleTo("UnityEngine.WindModule")] [assembly: InternalsVisibleTo("UnityEngine.VRModule")] [assembly: InternalsVisibleTo("UnityEngine.XRModule")] [assembly: InternalsVisibleTo("UnityEngine.VirtualTexturingModule")] [assembly: InternalsVisibleTo("UnityEngine.VideoModule")] [assembly: InternalsVisibleTo("UnityEngine.VFXModule")] [assembly: InternalsVisibleTo("UnityEngine.VehiclesModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityWebRequestWWWModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityWebRequestTextureModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityWebRequestAudioModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityWebRequestAssetBundleModule")] [assembly: InternalsVisibleTo("UnityEngine.ProfilerModule")] [assembly: InternalsVisibleTo("UnityEngine.Physics2DModule")] [assembly: InternalsVisibleTo("UnityEngine.ParticleSystemModule")] [assembly: InternalsVisibleTo("UnityEngine.Networking")] [assembly: InternalsVisibleTo("UnityEngine.AudioModule")] [assembly: InternalsVisibleTo("UnityEngine.AssetBundleModule")] [assembly: InternalsVisibleTo("UnityEngine.HotReloadModule")] [assembly: InternalsVisibleTo("UnityEngine.ARModule")] [assembly: InternalsVisibleTo("UnityEngine.InputModule")] [assembly: InternalsVisibleTo("UnityEngine.JSONSerializeModule")] [assembly: InternalsVisibleTo("UnityEngine.PhysicsModule")] [assembly: InternalsVisibleTo("UnityEngine.ClothModule")] [assembly: InternalsVisibleTo("UnityEngine.AnimationModule")] [assembly: InternalsVisibleTo("UnityEngine.AIModule")] [assembly: InternalsVisibleTo("UnityEngine.AccessibilityModule")] [assembly: InternalsVisibleTo("UnityEngine.CoreModule")] [assembly: InternalsVisibleTo("UnityEngine.SharedInternalsModule")] [assembly: InternalsVisibleTo("UnityEngine")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: InternalsVisibleTo("UnityEngine.AndroidJNIModule")] [assembly: InternalsVisibleTo("UnityEngine.PerformanceReportingModule")] [assembly: InternalsVisibleTo("UnityEngine.ClusterInputModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityConnectModule")] [assembly: InternalsVisibleTo("UnityEngine.NVIDIAModule")] [assembly: InternalsVisibleTo("UnityEngine.LocalizationModule")] [assembly: InternalsVisibleTo("UnityEngine.IMGUIModule")] [assembly: InternalsVisibleTo("UnityEngine.InputLegacyModule")] [assembly: InternalsVisibleTo("UnityEngine.TextRenderingModule")] [assembly: InternalsVisibleTo("UnityEngine.GridModule")] [assembly: InternalsVisibleTo("UnityEngine.GIModule")] [assembly: InternalsVisibleTo("UnityEngine.ClusterRendererModule")] [assembly: InternalsVisibleTo("UnityEngine.GameCenterModule")] [assembly: InternalsVisibleTo("UnityEngine.DSPGraphModule")] [assembly: InternalsVisibleTo("UnityEngine.DirectorModule")] [assembly: InternalsVisibleTo("UnityEngine.CrashReportingModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityAnalyticsModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityWebRequestModule")] [assembly: InternalsVisibleTo("UnityEngine.TLSModule")] [assembly: InternalsVisibleTo("UnityEngine.UnityAnalyticsCommonModule")] [assembly: InternalsVisibleTo("UnityEngine.ImageConversionModule")] [assembly: InternalsVisibleTo("UnityEngine.Cloud")] [assembly: InternalsVisibleTo("Unity.Analytics")] [assembly: CompilationRelaxations(8)] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.010")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.009")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.008")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.007")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.006")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.005")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.004")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.003")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.002")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.001")] [assembly: InternalsVisibleTo("Unity.Core")] [assembly: InternalsVisibleTo("Unity.Runtime")] [assembly: InternalsVisibleTo("Unity.Collections")] [assembly: InternalsVisibleTo("Unity.Entities.Tests")] [assembly: InternalsVisibleTo("Unity.Entities")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.011")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.012")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.013")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.014")] [assembly: InternalsVisibleTo("Unity.Subsystem.Registration")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridgeDev.005")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridgeDev.004")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridgeDev.003")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridgeDev.002")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridgeDev.001")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.024")] [assembly: InternalsVisibleTo("UnityEngine.Cloud.Service")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.023")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.021")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.020")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.019")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.018")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.017")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.016")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.015")] [assembly: InternalsVisibleTo("Unity.InternalAPIEngineBridge.022")] [assembly: InternalsVisibleTo("Unity.Services.QoS")] [assembly: InternalsVisibleTo("Unity.Logging")] [assembly: InternalsVisibleTo("Unity.Networking.Transport")] [assembly: InternalsVisibleTo("Unity.RuntimeTests.Framework")] [assembly: InternalsVisibleTo("Unity.RuntimeTests")] [assembly: InternalsVisibleTo("Unity.IntegrationTests.Framework")] [assembly: InternalsVisibleTo("Unity.IntegrationTests.Timeline")] [assembly: InternalsVisibleTo("Unity.IntegrationTests.UnityAnalytics")] [assembly: InternalsVisibleTo("Unity.IntegrationTests")] [assembly: InternalsVisibleTo("Unity.DeploymentTests.Services")] [assembly: InternalsVisibleTo("Unity.Burst.Editor")] [assembly: InternalsVisibleTo("Unity.Burst")] [assembly: InternalsVisibleTo("Unity.Automation")] [assembly: InternalsVisibleTo("UnityEngine.TestRunner")] [assembly: InternalsVisibleTo("UnityEngine.Purchasing")] [assembly: InternalsVisibleTo("UnityEngine.Advertisements")] [assembly: InternalsVisibleTo("UnityEngine.UnityAnalyticsCommon")] [assembly: InternalsVisibleTo("UnityEngine.Analytics")] [assembly: InternalsVisibleTo("Unity.RuntimeTests.Framework.Tests")] [assembly: InternalsVisibleTo("Unity.ucg.QoS")] [assembly: InternalsVisibleTo("Unity.PerformanceTests.RuntimeTestRunner.Tests")] [assembly: InternalsVisibleTo("Unity.Timeline")] [assembly: InternalsVisibleTo("UnityEngine.UI")] [assembly: InternalsVisibleTo("Unity.UIElements.EditorTests")] [assembly: InternalsVisibleTo("Unity.UIElements.PlayModeTests")] [assembly: InternalsVisibleTo("Unity.UIElements.Editor")] [assembly: InternalsVisibleTo("UnityEngine.UIElementsGameObjectsModule")] [assembly: InternalsVisibleTo("Unity.UIElements")] [assembly: InternalsVisibleTo("Unity.RuntimeTests.AllIn1Runner")] [assembly: InternalsVisibleTo("UnityEditor.UIBuilderModule")] [assembly: InternalsVisibleTo("Unity.UI.Builder.EditorTests")] [assembly: InternalsVisibleTo("Unity.2D.Sprite.EditorTests")] [assembly: InternalsVisibleTo("Unity.2D.Sprite.Editor")] [assembly: InternalsVisibleTo("Unity.WindowsMRAutomation")] [assembly: InternalsVisibleTo("GoogleAR.UnityNative")] [assembly: InternalsVisibleTo("UnityEngine.SpatialTracking")] [assembly: InternalsVisibleTo("Assembly-CSharp-firstpass-testable")] [assembly: InternalsVisibleTo("Assembly-CSharp-testable")] [assembly: InternalsVisibleTo("Unity.UI.Builder.Editor")] [assembly: UnityEngineModuleAssembly] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [Embedded] [CompilerGenerated] internal sealed class IsReadOnlyAttribute : Attribute { } } namespace UnityEngine.XR { [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputTrackingFacade.h")] [StaticAccessor(/*Could not decode attribute arguments.*/)] [RequiredByNativeCode] [NativeConditional("ENABLE_VR")] public static class InputTracking { private enum TrackingStateEventType { NodeAdded, NodeRemoved, TrackingAcquired, TrackingLost } [Obsolete("This API is obsolete, and should no longer be used. Please use the TrackedPoseDriver in the Legacy Input Helpers package for controlling a camera in XR.")] [NativeConditional("ENABLE_VR")] public static extern bool disablePositionalTracking { [MethodImpl(MethodImplOptions.InternalCall)] [NativeName("GetPositionalTrackingDisabled")] get; [MethodImpl(MethodImplOptions.InternalCall)] [NativeName("SetPositionalTrackingDisabled")] set; } public static event Action trackingAcquired; public static event Action trackingLost; public static event Action nodeAdded; public static event Action nodeRemoved; [RequiredByNativeCode] private static void InvokeTrackingEvent(TrackingStateEventType eventType, XRNode nodeType, long uniqueID, bool tracked) { Action action = null; XRNodeState obj = new XRNodeState { uniqueID = (ulong)uniqueID, nodeType = nodeType, tracked = tracked }; ((Action)(eventType switch { TrackingStateEventType.TrackingAcquired => InputTracking.trackingAcquired, TrackingStateEventType.TrackingLost => InputTracking.trackingLost, TrackingStateEventType.NodeAdded => InputTracking.nodeAdded, TrackingStateEventType.NodeRemoved => InputTracking.nodeRemoved, _ => throw new ArgumentException("TrackingEventHandler - Invalid EventType: " + eventType), }))?.Invoke(obj); } [Obsolete("This API is obsolete, and should no longer be used. Please use InputDevice.TryGetFeatureValue with the CommonUsages.devicePosition usage instead.")] [NativeConditional("ENABLE_VR", "Vector3f::zero")] public static Vector3 GetLocalPosition(XRNode node) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) GetLocalPosition_Injected(node, out var ret); return ret; } [Obsolete("This API is obsolete, and should no longer be used. Please use InputDevice.TryGetFeatureValue with the CommonUsages.deviceRotation usage instead.")] [NativeConditional("ENABLE_VR", "Quaternionf::identity()")] public static Quaternion GetLocalRotation(XRNode node) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) GetLocalRotation_Injected(node, out var ret); return ret; } [MethodImpl(MethodImplOptions.InternalCall)] [Obsolete("This API is obsolete, and should no longer be used. Please use XRInputSubsystem.TryRecenter() instead.")] [NativeConditional("ENABLE_VR")] public static extern void Recenter(); [MethodImpl(MethodImplOptions.InternalCall)] [NativeConditional("ENABLE_VR")] [Obsolete("This API is obsolete, and should no longer be used. Please use InputDevice.name with the device associated with that tracking data instead.")] public static extern string GetNodeName(ulong uniqueId); public static void GetNodeStates(List nodeStates) { if (nodeStates == null) { throw new ArgumentNullException("nodeStates"); } nodeStates.Clear(); GetNodeStates_Internal(nodeStates); } [MethodImpl(MethodImplOptions.InternalCall)] [NativeConditional("ENABLE_VR")] private static extern void GetNodeStates_Internal([NotNull("ArgumentNullException")] List nodeStates); [MethodImpl(MethodImplOptions.InternalCall)] [StaticAccessor(/*Could not decode attribute arguments.*/)] [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputTracking.h")] internal static extern ulong GetDeviceIdAtXRNode(XRNode node); [MethodImpl(MethodImplOptions.InternalCall)] [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputTracking.h")] [StaticAccessor(/*Could not decode attribute arguments.*/)] internal static extern void GetDeviceIdsAtXRNode_Internal(XRNode node, [NotNull("ArgumentNullException")] List deviceIds); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void GetLocalPosition_Injected(XRNode node, out Vector3 ret); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void GetLocalRotation_Injected(XRNode node, out Quaternion ret); } public enum XRNode { LeftEye, RightEye, CenterEye, Head, LeftHand, RightHand, GameController, TrackingReference, HardwareTracker } [Flags] internal enum AvailableTrackingData { None = 0, PositionAvailable = 1, RotationAvailable = 2, VelocityAvailable = 4, AngularVelocityAvailable = 8, AccelerationAvailable = 0x10, AngularAccelerationAvailable = 0x20 } [UsedByNativeCode] public struct XRNodeState { private XRNode m_Type; private AvailableTrackingData m_AvailableFields; private Vector3 m_Position; private Quaternion m_Rotation; private Vector3 m_Velocity; private Vector3 m_AngularVelocity; private Vector3 m_Acceleration; private Vector3 m_AngularAcceleration; private int m_Tracked; private ulong m_UniqueID; public ulong uniqueID { get { return m_UniqueID; } set { m_UniqueID = value; } } public XRNode nodeType { get { return m_Type; } set { m_Type = value; } } public bool tracked { get { return m_Tracked == 1; } set { m_Tracked = (value ? 1 : 0); } } public Vector3 position { set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_Position = value; m_AvailableFields |= AvailableTrackingData.PositionAvailable; } } public Quaternion rotation { set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_Rotation = value; m_AvailableFields |= AvailableTrackingData.RotationAvailable; } } public Vector3 velocity { set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_Velocity = value; m_AvailableFields |= AvailableTrackingData.VelocityAvailable; } } public Vector3 angularVelocity { set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_AngularVelocity = value; m_AvailableFields |= AvailableTrackingData.AngularVelocityAvailable; } } public Vector3 acceleration { set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_Acceleration = value; m_AvailableFields |= AvailableTrackingData.AccelerationAvailable; } } public Vector3 angularAcceleration { set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_AngularAcceleration = value; m_AvailableFields |= AvailableTrackingData.AngularAccelerationAvailable; } } public bool TryGetPosition(out Vector3 position) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryGet(m_Position, AvailableTrackingData.PositionAvailable, out position); } public bool TryGetRotation(out Quaternion rotation) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryGet(m_Rotation, AvailableTrackingData.RotationAvailable, out rotation); } public bool TryGetVelocity(out Vector3 velocity) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryGet(m_Velocity, AvailableTrackingData.VelocityAvailable, out velocity); } public bool TryGetAngularVelocity(out Vector3 angularVelocity) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryGet(m_AngularVelocity, AvailableTrackingData.AngularVelocityAvailable, out angularVelocity); } public bool TryGetAcceleration(out Vector3 acceleration) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryGet(m_Acceleration, AvailableTrackingData.AccelerationAvailable, out acceleration); } public bool TryGetAngularAcceleration(out Vector3 angularAcceleration) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryGet(m_AngularAcceleration, AvailableTrackingData.AngularAccelerationAvailable, out angularAcceleration); } private bool TryGet(Vector3 inValue, AvailableTrackingData availabilityFlag, out Vector3 outValue) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((m_AvailableFields & availabilityFlag) > AvailableTrackingData.None) { outValue = inValue; return true; } outValue = Vector3.zero; return false; } private bool TryGet(Quaternion inValue, AvailableTrackingData availabilityFlag, out Quaternion outValue) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((m_AvailableFields & availabilityFlag) > AvailableTrackingData.None) { outValue = inValue; return true; } outValue = Quaternion.identity; return false; } } [NativeConditional("ENABLE_VR")] public struct HapticCapabilities : IEquatable { private uint m_NumChannels; private bool m_SupportsImpulse; private bool m_SupportsBuffer; private uint m_BufferFrequencyHz; private uint m_BufferMaxSize; private uint m_BufferOptimalSize; public uint numChannels { get { return m_NumChannels; } internal set { m_NumChannels = value; } } public bool supportsImpulse { get { return m_SupportsImpulse; } internal set { m_SupportsImpulse = value; } } public bool supportsBuffer { get { return m_SupportsBuffer; } internal set { m_SupportsBuffer = value; } } public uint bufferFrequencyHz { get { return m_BufferFrequencyHz; } internal set { m_BufferFrequencyHz = value; } } public uint bufferMaxSize { get { return m_BufferMaxSize; } internal set { m_BufferMaxSize = value; } } public uint bufferOptimalSize { get { return m_BufferOptimalSize; } internal set { m_BufferOptimalSize = value; } } public override bool Equals(object obj) { if (!(obj is HapticCapabilities)) { return false; } return Equals((HapticCapabilities)obj); } public bool Equals(HapticCapabilities other) { return numChannels == other.numChannels && supportsImpulse == other.supportsImpulse && supportsBuffer == other.supportsBuffer && bufferFrequencyHz == other.bufferFrequencyHz && bufferMaxSize == other.bufferMaxSize && bufferOptimalSize == other.bufferOptimalSize; } public override int GetHashCode() { return numChannels.GetHashCode() ^ (supportsImpulse.GetHashCode() << 1) ^ (supportsBuffer.GetHashCode() >> 1) ^ (bufferFrequencyHz.GetHashCode() << 2) ^ (bufferMaxSize.GetHashCode() >> 2) ^ (bufferOptimalSize.GetHashCode() << 3); } public static bool operator ==(HapticCapabilities a, HapticCapabilities b) { return a.Equals(b); } public static bool operator !=(HapticCapabilities a, HapticCapabilities b) { return !(a == b); } } internal enum InputFeatureType : uint { Custom = 0u, Binary = 1u, DiscreteStates = 2u, Axis1D = 3u, Axis2D = 4u, Axis3D = 5u, Rotation = 6u, Hand = 7u, Bone = 8u, Eyes = 9u, kUnityXRInputFeatureTypeInvalid = uint.MaxValue } internal enum ConnectionChangeType : uint { Connected, Disconnected, ConfigChange } public enum InputDeviceRole : uint { Unknown, Generic, LeftHanded, RightHanded, GameController, TrackingReference, HardwareTracker, LegacyController } [Flags] public enum InputDeviceCharacteristics : uint { None = 0u, HeadMounted = 1u, Camera = 2u, HeldInHand = 4u, HandTracking = 8u, EyeTracking = 0x10u, TrackedDevice = 0x20u, Controller = 0x40u, TrackingReference = 0x80u, Left = 0x100u, Right = 0x200u, Simulated6DOF = 0x400u } [Flags] public enum InputTrackingState : uint { None = 0u, Position = 1u, Rotation = 2u, Velocity = 4u, AngularVelocity = 8u, Acceleration = 0x10u, AngularAcceleration = 0x20u, All = 0x3Fu } [NativeConditional("ENABLE_VR")] [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputDevices.h")] [RequiredByNativeCode] public struct InputFeatureUsage : IEquatable { internal string m_Name; [NativeName("m_FeatureType")] internal InputFeatureType m_InternalType; public string name { get { return m_Name; } internal set { m_Name = value; } } internal InputFeatureType internalType { get { return m_InternalType; } set { m_InternalType = value; } } public Type type => m_InternalType switch { InputFeatureType.Custom => typeof(byte[]), InputFeatureType.Binary => typeof(bool), InputFeatureType.DiscreteStates => typeof(uint), InputFeatureType.Axis1D => typeof(float), InputFeatureType.Axis2D => typeof(Vector2), InputFeatureType.Axis3D => typeof(Vector3), InputFeatureType.Rotation => typeof(Quaternion), InputFeatureType.Hand => typeof(Hand), InputFeatureType.Bone => typeof(Bone), InputFeatureType.Eyes => typeof(Eyes), _ => throw new InvalidCastException("No valid managed type for unknown native type."), }; internal InputFeatureUsage(string name, InputFeatureType type) { m_Name = name; m_InternalType = type; } public override bool Equals(object obj) { if (!(obj is InputFeatureUsage)) { return false; } return Equals((InputFeatureUsage)obj); } public bool Equals(InputFeatureUsage other) { return name == other.name && internalType == other.internalType; } public override int GetHashCode() { return name.GetHashCode() ^ (internalType.GetHashCode() << 1); } public static bool operator ==(InputFeatureUsage a, InputFeatureUsage b) { return a.Equals(b); } public static bool operator !=(InputFeatureUsage a, InputFeatureUsage b) { return !(a == b); } public InputFeatureUsage As() { if ((object)type != typeof(T)) { throw new ArgumentException("InputFeatureUsage type does not match out variable type."); } return new InputFeatureUsage(name); } } public struct InputFeatureUsage : IEquatable> { public string name { get; set; } private Type usageType => typeof(T); public InputFeatureUsage(string usageName) { name = usageName; } public override bool Equals(object obj) { if (!(obj is InputFeatureUsage)) { return false; } return Equals((InputFeatureUsage)obj); } public bool Equals(InputFeatureUsage other) { return name == other.name; } public override int GetHashCode() { return name.GetHashCode(); } public static bool operator ==(InputFeatureUsage a, InputFeatureUsage b) { return a.Equals(b); } public static bool operator !=(InputFeatureUsage a, InputFeatureUsage b) { return !(a == b); } public static explicit operator InputFeatureUsage(InputFeatureUsage self) { InputFeatureType inputFeatureType = InputFeatureType.kUnityXRInputFeatureTypeInvalid; Type type = self.usageType; if ((object)type == typeof(bool)) { inputFeatureType = InputFeatureType.Binary; } else if ((object)type == typeof(uint)) { inputFeatureType = InputFeatureType.DiscreteStates; } else if ((object)type == typeof(float)) { inputFeatureType = InputFeatureType.Axis1D; } else if ((object)type == typeof(Vector2)) { inputFeatureType = InputFeatureType.Axis2D; } else if ((object)type == typeof(Vector3)) { inputFeatureType = InputFeatureType.Axis3D; } else if ((object)type == typeof(Quaternion)) { inputFeatureType = InputFeatureType.Rotation; } else if ((object)type == typeof(Hand)) { inputFeatureType = InputFeatureType.Hand; } else if ((object)type == typeof(Bone)) { inputFeatureType = InputFeatureType.Bone; } else if ((object)type == typeof(Eyes)) { inputFeatureType = InputFeatureType.Eyes; } else if ((object)type == typeof(byte[])) { inputFeatureType = InputFeatureType.Custom; } else if (type.IsEnum) { inputFeatureType = InputFeatureType.DiscreteStates; } if (inputFeatureType != InputFeatureType.kUnityXRInputFeatureTypeInvalid) { return new InputFeatureUsage(self.name, inputFeatureType); } throw new InvalidCastException("No valid InputFeatureType for " + self.name + "."); } } public static class CommonUsages { public static InputFeatureUsage isTracked = new InputFeatureUsage("IsTracked"); public static InputFeatureUsage primaryButton = new InputFeatureUsage("PrimaryButton"); public static InputFeatureUsage primaryTouch = new InputFeatureUsage("PrimaryTouch"); public static InputFeatureUsage secondaryButton = new InputFeatureUsage("SecondaryButton"); public static InputFeatureUsage secondaryTouch = new InputFeatureUsage("SecondaryTouch"); public static InputFeatureUsage gripButton = new InputFeatureUsage("GripButton"); public static InputFeatureUsage triggerButton = new InputFeatureUsage("TriggerButton"); public static InputFeatureUsage menuButton = new InputFeatureUsage("MenuButton"); public static InputFeatureUsage primary2DAxisClick = new InputFeatureUsage("Primary2DAxisClick"); public static InputFeatureUsage primary2DAxisTouch = new InputFeatureUsage("Primary2DAxisTouch"); public static InputFeatureUsage secondary2DAxisClick = new InputFeatureUsage("Secondary2DAxisClick"); public static InputFeatureUsage secondary2DAxisTouch = new InputFeatureUsage("Secondary2DAxisTouch"); public static InputFeatureUsage userPresence = new InputFeatureUsage("UserPresence"); public static InputFeatureUsage trackingState = new InputFeatureUsage("TrackingState"); public static InputFeatureUsage batteryLevel = new InputFeatureUsage("BatteryLevel"); public static InputFeatureUsage trigger = new InputFeatureUsage("Trigger"); public static InputFeatureUsage grip = new InputFeatureUsage("Grip"); public static InputFeatureUsage primary2DAxis = new InputFeatureUsage("Primary2DAxis"); public static InputFeatureUsage secondary2DAxis = new InputFeatureUsage("Secondary2DAxis"); public static InputFeatureUsage devicePosition = new InputFeatureUsage("DevicePosition"); public static InputFeatureUsage leftEyePosition = new InputFeatureUsage("LeftEyePosition"); public static InputFeatureUsage rightEyePosition = new InputFeatureUsage("RightEyePosition"); public static InputFeatureUsage centerEyePosition = new InputFeatureUsage("CenterEyePosition"); public static InputFeatureUsage colorCameraPosition = new InputFeatureUsage("CameraPosition"); public static InputFeatureUsage deviceVelocity = new InputFeatureUsage("DeviceVelocity"); public static InputFeatureUsage deviceAngularVelocity = new InputFeatureUsage("DeviceAngularVelocity"); public static InputFeatureUsage leftEyeVelocity = new InputFeatureUsage("LeftEyeVelocity"); public static InputFeatureUsage leftEyeAngularVelocity = new InputFeatureUsage("LeftEyeAngularVelocity"); public static InputFeatureUsage rightEyeVelocity = new InputFeatureUsage("RightEyeVelocity"); public static InputFeatureUsage rightEyeAngularVelocity = new InputFeatureUsage("RightEyeAngularVelocity"); public static InputFeatureUsage centerEyeVelocity = new InputFeatureUsage("CenterEyeVelocity"); public static InputFeatureUsage centerEyeAngularVelocity = new InputFeatureUsage("CenterEyeAngularVelocity"); public static InputFeatureUsage colorCameraVelocity = new InputFeatureUsage("CameraVelocity"); public static InputFeatureUsage colorCameraAngularVelocity = new InputFeatureUsage("CameraAngularVelocity"); public static InputFeatureUsage deviceAcceleration = new InputFeatureUsage("DeviceAcceleration"); public static InputFeatureUsage deviceAngularAcceleration = new InputFeatureUsage("DeviceAngularAcceleration"); public static InputFeatureUsage leftEyeAcceleration = new InputFeatureUsage("LeftEyeAcceleration"); public static InputFeatureUsage leftEyeAngularAcceleration = new InputFeatureUsage("LeftEyeAngularAcceleration"); public static InputFeatureUsage rightEyeAcceleration = new InputFeatureUsage("RightEyeAcceleration"); public static InputFeatureUsage rightEyeAngularAcceleration = new InputFeatureUsage("RightEyeAngularAcceleration"); public static InputFeatureUsage centerEyeAcceleration = new InputFeatureUsage("CenterEyeAcceleration"); public static InputFeatureUsage centerEyeAngularAcceleration = new InputFeatureUsage("CenterEyeAngularAcceleration"); public static InputFeatureUsage colorCameraAcceleration = new InputFeatureUsage("CameraAcceleration"); public static InputFeatureUsage colorCameraAngularAcceleration = new InputFeatureUsage("CameraAngularAcceleration"); public static InputFeatureUsage deviceRotation = new InputFeatureUsage("DeviceRotation"); public static InputFeatureUsage leftEyeRotation = new InputFeatureUsage("LeftEyeRotation"); public static InputFeatureUsage rightEyeRotation = new InputFeatureUsage("RightEyeRotation"); public static InputFeatureUsage centerEyeRotation = new InputFeatureUsage("CenterEyeRotation"); public static InputFeatureUsage colorCameraRotation = new InputFeatureUsage("CameraRotation"); public static InputFeatureUsage handData = new InputFeatureUsage("HandData"); public static InputFeatureUsage eyesData = new InputFeatureUsage("EyesData"); [Obsolete("CommonUsages.dPad is not used by any XR platform and will be removed.")] public static InputFeatureUsage dPad = new InputFeatureUsage("DPad"); [Obsolete("CommonUsages.indexFinger is not used by any XR platform and will be removed.")] public static InputFeatureUsage indexFinger = new InputFeatureUsage("IndexFinger"); [Obsolete("CommonUsages.MiddleFinger is not used by any XR platform and will be removed.")] public static InputFeatureUsage middleFinger = new InputFeatureUsage("MiddleFinger"); [Obsolete("CommonUsages.RingFinger is not used by any XR platform and will be removed.")] public static InputFeatureUsage ringFinger = new InputFeatureUsage("RingFinger"); [Obsolete("CommonUsages.PinkyFinger is not used by any XR platform and will be removed.")] public static InputFeatureUsage pinkyFinger = new InputFeatureUsage("PinkyFinger"); [Obsolete("CommonUsages.thumbrest is Oculus only, and is being moved to their package. Please use OculusUsages.thumbrest. These will still function until removed.")] public static InputFeatureUsage thumbrest = new InputFeatureUsage("Thumbrest"); [Obsolete("CommonUsages.indexTouch is Oculus only, and is being moved to their package. Please use OculusUsages.indexTouch. These will still function until removed.")] public static InputFeatureUsage indexTouch = new InputFeatureUsage("IndexTouch"); [Obsolete("CommonUsages.thumbTouch is Oculus only, and is being moved to their package. Please use OculusUsages.thumbTouch. These will still function until removed.")] public static InputFeatureUsage thumbTouch = new InputFeatureUsage("ThumbTouch"); } [UsedByNativeCode] [NativeConditional("ENABLE_VR")] public struct InputDevice : IEquatable { private static List s_InputSubsystemCache; private ulong m_DeviceId; private bool m_Initialized; private ulong deviceId => m_Initialized ? m_DeviceId : ulong.MaxValue; public XRInputSubsystem subsystem { get { if (s_InputSubsystemCache == null) { s_InputSubsystemCache = new List(); } if (m_Initialized) { uint num = (uint)(m_DeviceId >> 32); SubsystemManager.GetSubsystems(s_InputSubsystemCache); for (int i = 0; i < s_InputSubsystemCache.Count; i++) { if (num == s_InputSubsystemCache[i].GetIndex()) { return s_InputSubsystemCache[i]; } } } return null; } } public bool isValid => IsValidId() && InputDevices.IsDeviceValid(m_DeviceId); public string name => IsValidId() ? InputDevices.GetDeviceName(m_DeviceId) : null; [Obsolete("This API has been marked as deprecated and will be removed in future versions. Please use InputDevice.characteristics instead.")] public InputDeviceRole role => IsValidId() ? InputDevices.GetDeviceRole(m_DeviceId) : InputDeviceRole.Unknown; public string manufacturer => IsValidId() ? InputDevices.GetDeviceManufacturer(m_DeviceId) : null; public string serialNumber => IsValidId() ? InputDevices.GetDeviceSerialNumber(m_DeviceId) : null; public InputDeviceCharacteristics characteristics => IsValidId() ? InputDevices.GetDeviceCharacteristics(m_DeviceId) : InputDeviceCharacteristics.None; internal InputDevice(ulong deviceId) { m_DeviceId = deviceId; m_Initialized = true; } private bool IsValidId() { return deviceId != ulong.MaxValue; } public bool SendHapticImpulse(uint channel, float amplitude, float duration = 1f) { if (!IsValidId()) { return false; } if (amplitude < 0f) { throw new ArgumentException("Amplitude of SendHapticImpulse cannot be negative."); } if (duration < 0f) { throw new ArgumentException("Duration of SendHapticImpulse cannot be negative."); } return InputDevices.SendHapticImpulse(m_DeviceId, channel, amplitude, duration); } public bool SendHapticBuffer(uint channel, byte[] buffer) { if (!IsValidId()) { return false; } return InputDevices.SendHapticBuffer(m_DeviceId, channel, buffer); } public bool TryGetHapticCapabilities(out HapticCapabilities capabilities) { if (CheckValidAndSetDefault(out capabilities)) { return InputDevices.TryGetHapticCapabilities(m_DeviceId, out capabilities); } return false; } public void StopHaptics() { if (IsValidId()) { InputDevices.StopHaptics(m_DeviceId); } } public bool TryGetFeatureUsages(List featureUsages) { if (IsValidId()) { return InputDevices.TryGetFeatureUsages(m_DeviceId, featureUsages); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out bool value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_bool(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out uint value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_UInt32(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out float value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_float(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out Vector2 value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_Vector2f(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out Vector3 value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_Vector3f(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out Quaternion value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_Quaternionf(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out Hand value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_XRHand(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out Bone value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_XRBone(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out Eyes value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValue_XREyes(m_DeviceId, usage.name, out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, byte[] value) { if (IsValidId()) { return InputDevices.TryGetFeatureValue_Custom(m_DeviceId, usage.name, value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, out InputTrackingState value) { if (IsValidId()) { uint value2 = 0u; if (InputDevices.TryGetFeatureValue_UInt32(m_DeviceId, usage.name, out value2)) { value = (InputTrackingState)value2; return true; } } value = InputTrackingState.None; return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, DateTime time, out bool value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValueAtTime_bool(m_DeviceId, usage.name, TimeConverter.LocalDateTimeToUnixTimeMilliseconds(time), out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, DateTime time, out uint value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValueAtTime_UInt32(m_DeviceId, usage.name, TimeConverter.LocalDateTimeToUnixTimeMilliseconds(time), out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, DateTime time, out float value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValueAtTime_float(m_DeviceId, usage.name, TimeConverter.LocalDateTimeToUnixTimeMilliseconds(time), out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, DateTime time, out Vector2 value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValueAtTime_Vector2f(m_DeviceId, usage.name, TimeConverter.LocalDateTimeToUnixTimeMilliseconds(time), out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, DateTime time, out Vector3 value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValueAtTime_Vector3f(m_DeviceId, usage.name, TimeConverter.LocalDateTimeToUnixTimeMilliseconds(time), out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, DateTime time, out Quaternion value) { if (CheckValidAndSetDefault(out value)) { return InputDevices.TryGetFeatureValueAtTime_Quaternionf(m_DeviceId, usage.name, TimeConverter.LocalDateTimeToUnixTimeMilliseconds(time), out value); } return false; } public bool TryGetFeatureValue(InputFeatureUsage usage, DateTime time, out InputTrackingState value) { if (IsValidId()) { uint value2 = 0u; if (InputDevices.TryGetFeatureValueAtTime_UInt32(m_DeviceId, usage.name, TimeConverter.LocalDateTimeToUnixTimeMilliseconds(time), out value2)) { value = (InputTrackingState)value2; return true; } } value = InputTrackingState.None; return false; } private bool CheckValidAndSetDefault(out T value) { value = default(T); return IsValidId(); } public override bool Equals(object obj) { if (!(obj is InputDevice)) { return false; } return Equals((InputDevice)obj); } public bool Equals(InputDevice other) { return deviceId == other.deviceId; } public override int GetHashCode() { return deviceId.GetHashCode(); } public static bool operator ==(InputDevice a, InputDevice b) { return a.Equals(b); } public static bool operator !=(InputDevice a, InputDevice b) { return !(a == b); } } internal static class TimeConverter { private static readonly DateTime s_Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); public static DateTime now => DateTime.Now; public static long LocalDateTimeToUnixTimeMilliseconds(DateTime date) { return Convert.ToInt64((date.ToUniversalTime() - s_Epoch).TotalMilliseconds); } public static DateTime UnixTimeMillisecondsToLocalDateTime(long unixTimeInMilliseconds) { DateTime dateTime = s_Epoch; return dateTime.AddMilliseconds(unixTimeInMilliseconds).ToLocalTime(); } } public enum HandFinger { Thumb, Index, Middle, Ring, Pinky } [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputDevices.h")] [NativeHeader("XRScriptingClasses.h")] [NativeHeader("Modules/XR/XRPrefix.h")] [NativeConditional("ENABLE_VR")] [RequiredByNativeCode] [StaticAccessor(/*Could not decode attribute arguments.*/)] public struct Hand : IEquatable { private ulong m_DeviceId; private uint m_FeatureIndex; internal ulong deviceId => m_DeviceId; internal uint featureIndex => m_FeatureIndex; public bool TryGetRootBone(out Bone boneOut) { return Hand_TryGetRootBone(this, out boneOut); } private static bool Hand_TryGetRootBone(Hand hand, out Bone boneOut) { return Hand_TryGetRootBone_Injected(ref hand, out boneOut); } public bool TryGetFingerBones(HandFinger finger, List bonesOut) { if (bonesOut == null) { throw new ArgumentNullException("bonesOut"); } return Hand_TryGetFingerBonesAsList(this, finger, bonesOut); } private static bool Hand_TryGetFingerBonesAsList(Hand hand, HandFinger finger, [NotNull("ArgumentNullException")] List bonesOut) { return Hand_TryGetFingerBonesAsList_Injected(ref hand, finger, bonesOut); } public override bool Equals(object obj) { if (!(obj is Hand)) { return false; } return Equals((Hand)obj); } public bool Equals(Hand other) { return deviceId == other.deviceId && featureIndex == other.featureIndex; } public override int GetHashCode() { return deviceId.GetHashCode() ^ (featureIndex.GetHashCode() << 1); } public static bool operator ==(Hand a, Hand b) { return a.Equals(b); } public static bool operator !=(Hand a, Hand b) { return !(a == b); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Hand_TryGetRootBone_Injected(ref Hand hand, out Bone boneOut); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Hand_TryGetFingerBonesAsList_Injected(ref Hand hand, HandFinger finger, List bonesOut); } internal enum EyeSide { Left, Right } [RequiredByNativeCode] [NativeHeader("XRScriptingClasses.h")] [NativeConditional("ENABLE_VR")] [NativeHeader("Modules/XR/XRPrefix.h")] [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputDevices.h")] [StaticAccessor(/*Could not decode attribute arguments.*/)] public struct Eyes : IEquatable { private ulong m_DeviceId; private uint m_FeatureIndex; internal ulong deviceId => m_DeviceId; internal uint featureIndex => m_FeatureIndex; public bool TryGetLeftEyePosition(out Vector3 position) { return Eyes_TryGetEyePosition(this, EyeSide.Left, out position); } public bool TryGetRightEyePosition(out Vector3 position) { return Eyes_TryGetEyePosition(this, EyeSide.Right, out position); } public bool TryGetLeftEyeRotation(out Quaternion rotation) { return Eyes_TryGetEyeRotation(this, EyeSide.Left, out rotation); } public bool TryGetRightEyeRotation(out Quaternion rotation) { return Eyes_TryGetEyeRotation(this, EyeSide.Right, out rotation); } private static bool Eyes_TryGetEyePosition(Eyes eyes, EyeSide chirality, out Vector3 position) { return Eyes_TryGetEyePosition_Injected(ref eyes, chirality, out position); } private static bool Eyes_TryGetEyeRotation(Eyes eyes, EyeSide chirality, out Quaternion rotation) { return Eyes_TryGetEyeRotation_Injected(ref eyes, chirality, out rotation); } public bool TryGetFixationPoint(out Vector3 fixationPoint) { return Eyes_TryGetFixationPoint(this, out fixationPoint); } private static bool Eyes_TryGetFixationPoint(Eyes eyes, out Vector3 fixationPoint) { return Eyes_TryGetFixationPoint_Injected(ref eyes, out fixationPoint); } public bool TryGetLeftEyeOpenAmount(out float openAmount) { return Eyes_TryGetEyeOpenAmount(this, EyeSide.Left, out openAmount); } public bool TryGetRightEyeOpenAmount(out float openAmount) { return Eyes_TryGetEyeOpenAmount(this, EyeSide.Right, out openAmount); } private static bool Eyes_TryGetEyeOpenAmount(Eyes eyes, EyeSide chirality, out float openAmount) { return Eyes_TryGetEyeOpenAmount_Injected(ref eyes, chirality, out openAmount); } public override bool Equals(object obj) { if (!(obj is Eyes)) { return false; } return Equals((Eyes)obj); } public bool Equals(Eyes other) { return deviceId == other.deviceId && featureIndex == other.featureIndex; } public override int GetHashCode() { return deviceId.GetHashCode() ^ (featureIndex.GetHashCode() << 1); } public static bool operator ==(Eyes a, Eyes b) { return a.Equals(b); } public static bool operator !=(Eyes a, Eyes b) { return !(a == b); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Eyes_TryGetEyePosition_Injected(ref Eyes eyes, EyeSide chirality, out Vector3 position); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Eyes_TryGetEyeRotation_Injected(ref Eyes eyes, EyeSide chirality, out Quaternion rotation); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Eyes_TryGetFixationPoint_Injected(ref Eyes eyes, out Vector3 fixationPoint); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Eyes_TryGetEyeOpenAmount_Injected(ref Eyes eyes, EyeSide chirality, out float openAmount); } [StaticAccessor(/*Could not decode attribute arguments.*/)] [NativeConditional("ENABLE_VR")] [NativeHeader("Modules/XR/XRPrefix.h")] [NativeHeader("XRScriptingClasses.h")] [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputDevices.h")] [RequiredByNativeCode] public struct Bone : IEquatable { private ulong m_DeviceId; private uint m_FeatureIndex; internal ulong deviceId => m_DeviceId; internal uint featureIndex => m_FeatureIndex; public bool TryGetPosition(out Vector3 position) { return Bone_TryGetPosition(this, out position); } private static bool Bone_TryGetPosition(Bone bone, out Vector3 position) { return Bone_TryGetPosition_Injected(ref bone, out position); } public bool TryGetRotation(out Quaternion rotation) { return Bone_TryGetRotation(this, out rotation); } private static bool Bone_TryGetRotation(Bone bone, out Quaternion rotation) { return Bone_TryGetRotation_Injected(ref bone, out rotation); } public bool TryGetParentBone(out Bone parentBone) { return Bone_TryGetParentBone(this, out parentBone); } private static bool Bone_TryGetParentBone(Bone bone, out Bone parentBone) { return Bone_TryGetParentBone_Injected(ref bone, out parentBone); } public bool TryGetChildBones(List childBones) { return Bone_TryGetChildBones(this, childBones); } private static bool Bone_TryGetChildBones(Bone bone, [NotNull("ArgumentNullException")] List childBones) { return Bone_TryGetChildBones_Injected(ref bone, childBones); } public override bool Equals(object obj) { if (!(obj is Bone)) { return false; } return Equals((Bone)obj); } public bool Equals(Bone other) { return deviceId == other.deviceId && featureIndex == other.featureIndex; } public override int GetHashCode() { return deviceId.GetHashCode() ^ (featureIndex.GetHashCode() << 1); } public static bool operator ==(Bone a, Bone b) { return a.Equals(b); } public static bool operator !=(Bone a, Bone b) { return !(a == b); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Bone_TryGetPosition_Injected(ref Bone bone, out Vector3 position); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Bone_TryGetRotation_Injected(ref Bone bone, out Quaternion rotation); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Bone_TryGetParentBone_Injected(ref Bone bone, out Bone parentBone); [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool Bone_TryGetChildBones_Injected(ref Bone bone, List childBones); } [StructLayout(LayoutKind.Sequential)] [NativeConditional("ENABLE_VR")] [UsedByNativeCode] [StaticAccessor(/*Could not decode attribute arguments.*/)] [NativeHeader("Modules/XR/Subsystems/Input/Public/XRInputDevices.h")] public class InputDevices { private static List s_InputDeviceList; public static event Action deviceConnected; public static event Action deviceDisconnected; public static event Action deviceConfigChanged; public static InputDevice GetDeviceAtXRNode(XRNode node) { ulong deviceIdAtXRNode = InputTracking.GetDeviceIdAtXRNode(node); return new InputDevice(deviceIdAtXRNode); } public static void GetDevicesAtXRNode(XRNode node, List inputDevices) { if (inputDevices == null) { throw new ArgumentNullException("inputDevices"); } List list = new List(); InputTracking.GetDeviceIdsAtXRNode_Internal(node, list); inputDevices.Clear(); foreach (ulong item2 in list) { InputDevice item = new InputDevice(item2); if (item.isValid) { inputDevices.Add(item); } } } public static void GetDevices(List inputDevices) { if (inputDevices == null) { throw new ArgumentNullException("inputDevices"); } inputDevices.Clear(); GetDevices_Internal(inputDevices); } [Obsolete("This API has been marked as deprecated and will be removed in future versions. Please use InputDevices.GetDevicesWithCharacteristics instead.")] public static void GetDevicesWithRole(InputDeviceRole role, List inputDevices) { if (inputDevices == null) { throw new ArgumentNullException("inputDevices"); } if (s_InputDeviceList == null) { s_InputDeviceList = new List(); } GetDevices_Internal(s_InputDeviceList); inputDevices.Clear(); foreach (InputDevice s_InputDevice in s_InputDeviceList) { if (s_InputDevice.role == role) { inputDevices.Add(s_InputDevice); } } } public static void GetDevicesWithCharacteristics(InputDeviceCharacteristics desiredCharacteristics, List inputDevices) { if (inputDevices == null) { throw new ArgumentNullException("inputDevices"); } if (s_InputDeviceList == null) { s_InputDeviceList = new List(); } GetDevices_Internal(s_InputDeviceList); inputDevices.Clear(); foreach (InputDevice s_InputDevice in s_InputDeviceList) { if ((s_InputDevice.characteristics & desiredCharacteristics) == desiredCharacteristics) { inputDevices.Add(s_InputDevice); } } } [RequiredByNativeCode] private static void InvokeConnectionEvent(ulong deviceId, ConnectionChangeType change) { switch (change) { case ConnectionChangeType.Connected: if (InputDevices.deviceConnected != null) { InputDevices.deviceConnected(new InputDevice(deviceId)); } break; case ConnectionChangeType.Disconnected: if (InputDevices.deviceDisconnected != null) { InputDevices.deviceDisconnected(new InputDevice(deviceId)); } break; case ConnectionChangeType.ConfigChange: if (InputDevices.deviceConfigChanged != null) { InputDevices.deviceConfigChanged(new InputDevice(deviceId)); } break; } } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void GetDevices_Internal([NotNull("ArgumentNullException")] List inputDevices); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool SendHapticImpulse(ulong deviceId, uint channel, float amplitude, float duration); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool SendHapticBuffer(ulong deviceId, uint channel, [NotNull("ArgumentNullException")] byte[] buffer); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetHapticCapabilities(ulong deviceId, out HapticCapabilities capabilities); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void StopHaptics(ulong deviceId); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureUsages(ulong deviceId, [NotNull("ArgumentNullException")] List featureUsages); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_bool(ulong deviceId, string usage, out bool value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_UInt32(ulong deviceId, string usage, out uint value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_float(ulong deviceId, string usage, out float value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_Vector2f(ulong deviceId, string usage, out Vector2 value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_Vector3f(ulong deviceId, string usage, out Vector3 value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_Quaternionf(ulong deviceId, string usage, out Quaternion value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_Custom(ulong deviceId, string usage, [Out] byte[] value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValueAtTime_bool(ulong deviceId, string usage, long time, out bool value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValueAtTime_UInt32(ulong deviceId, string usage, long time, out uint value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValueAtTime_float(ulong deviceId, string usage, long time, out float value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValueAtTime_Vector2f(ulong deviceId, string usage, long time, out Vector2 value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValueAtTime_Vector3f(ulong deviceId, string usage, long time, out Vector3 value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValueAtTime_Quaternionf(ulong deviceId, string usage, long time, out Quaternion value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_XRHand(ulong deviceId, string usage, out Hand value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_XRBone(ulong deviceId, string usage, out Bone value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool TryGetFeatureValue_XREyes(ulong deviceId, string usage, out Eyes value); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool IsDeviceValid(ulong deviceId); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern string GetDeviceName(ulong deviceId); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern string GetDeviceManufacturer(ulong deviceId); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern string GetDeviceSerialNumber(ulong deviceId); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern InputDeviceCharacteristics GetDeviceCharacteristics(ulong deviceId); internal static InputDeviceRole GetDeviceRole(ulong deviceId) { InputDeviceCharacteristics deviceCharacteristics = GetDeviceCharacteristics(deviceId); if ((deviceCharacteristics & (InputDeviceCharacteristics.HeadMounted | InputDeviceCharacteristics.TrackedDevice)) == (InputDeviceCharacteristics.HeadMounted | InputDeviceCharacteristics.TrackedDevice)) { return InputDeviceRole.Generic; } if ((deviceCharacteristics & (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Left)) == (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Left)) { return InputDeviceRole.LeftHanded; } if ((deviceCharacteristics & (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Right)) == (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Right)) { return InputDeviceRole.RightHanded; } if ((deviceCharacteristics & InputDeviceCharacteristics.Controller) == InputDeviceCharacteristics.Controller) { return InputDeviceRole.GameController; } if ((deviceCharacteristics & (InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.TrackingReference)) == (InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.TrackingReference)) { return InputDeviceRole.TrackingReference; } if ((deviceCharacteristics & InputDeviceCharacteristics.TrackedDevice) == InputDeviceCharacteristics.TrackedDevice) { return InputDeviceRole.HardwareTracker; } return InputDeviceRole.Unknown; } } [NativeHeader("Modules/XR/XRPrefix.h")] [UsedByNativeCode] [NativeType(Header = "Modules/XR/Subsystems/Display/XRDisplaySubsystem.h")] [NativeConditional("ENABLE_XR")] public class XRDisplaySubsystem : IntegratedSubsystem { public enum LateLatchNode { Head, LeftHand, RightHand } [Flags] public enum TextureLayout { Texture2DArray = 1, SingleTexture2D = 2, SeparateTexture2Ds = 4 } public enum ReprojectionMode { Unspecified, PositionAndOrientation, OrientationOnly, None } [NativeHeader("Modules/XR/Subsystems/Display/XRDisplaySubsystem.bindings.h")] public struct XRRenderParameter { public Matrix4x4 view; public Matrix4x4 projection; public Rect viewport; public Mesh occlusionMesh; public int textureArraySlice; public Matrix4x4 previousView; public bool isPreviousViewValid; } [NativeHeader("Runtime/Graphics/RenderTextureDesc.h")] [NativeHeader("Modules/XR/Subsystems/Display/XRDisplaySubsystem.bindings.h")] [NativeHeader("Runtime/Graphics/CommandBuffer/RenderingCommandBuffer.h")] public struct XRRenderPass { private IntPtr displaySubsystemInstance; public int renderPassIndex; public RenderTargetIdentifier renderTarget; public RenderTextureDescriptor renderTargetDesc; public bool hasMotionVectorPass; public RenderTargetIdentifier motionVectorRenderTarget; public RenderTextureDescriptor motionVectorRenderTargetDesc; public bool shouldFillOutDepth; public int cullingPassIndex; [NativeMethod(Name = "XRRenderPassScriptApi::GetRenderParameter", IsFreeFunction = true, HasExplicitThis = true, ThrowsException = true)] [NativeConditional("ENABLE_XR")] public void GetRenderParameter(Camera camera, int renderParameterIndex, out XRRenderParameter renderParameter) { GetRenderParameter_Injected(ref this, camera, renderParameterIndex, out renderParameter); } [NativeMethod(Name = "XRRenderPassScriptApi::GetRenderParameterCount", IsFreeFunction = true, HasExplicitThis = true)] [NativeConditional("ENABLE_XR")] public int GetRenderParameterCount() { return GetRenderParameterCount_Injected(ref this); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void GetRenderParameter_Injected(ref XRRenderPass _unity_self, Camera camera, int renderParameterIndex, out XRRenderParameter renderParameter); [MethodImpl(MethodImplOptions.InternalCall)] private static extern int GetRenderParameterCount_Injected(ref XRRenderPass _unity_self); } [NativeHeader("Runtime/Graphics/RenderTexture.h")] [NativeHeader("Modules/XR/Subsystems/Display/XRDisplaySubsystem.bindings.h")] public struct XRBlitParams { public RenderTexture srcTex; public int srcTexArraySlice; public Rect srcRect; public Rect destRect; } [NativeHeader("Modules/XR/Subsystems/Display/XRDisplaySubsystem.bindings.h")] public struct XRMirrorViewBlitDesc { private IntPtr displaySubsystemInstance; public bool nativeBlitAvailable; public bool nativeBlitInvalidStates; public int blitParamsCount; [NativeMethod(Name = "XRMirrorViewBlitDescScriptApi::GetBlitParameter", IsFreeFunction = true, HasExplicitThis = true)] [NativeConditional("ENABLE_XR")] public void GetBlitParameter(int blitParameterIndex, out XRBlitParams blitParameter) { GetBlitParameter_Injected(ref this, blitParameterIndex, out blitParameter); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void GetBlitParameter_Injected(ref XRMirrorViewBlitDesc _unity_self, int blitParameterIndex, out XRBlitParams blitParameter); } [Obsolete("singlePassRenderingDisabled{get;set;} is deprecated. Use textureLayout and supportedTextureLayouts instead.", false)] public bool singlePassRenderingDisabled { get { return (textureLayout & TextureLayout.Texture2DArray) == 0; } set { if (value) { textureLayout = TextureLayout.SeparateTexture2Ds; } else if ((supportedTextureLayouts & TextureLayout.Texture2DArray) > (TextureLayout)0) { textureLayout = TextureLayout.Texture2DArray; } } } public extern bool displayOpaque { [MethodImpl(MethodImplOptions.InternalCall)] get; } public extern bool contentProtectionEnabled { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern float scaleOfAllViewports { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern float scaleOfAllRenderTargets { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern float zNear { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern float zFar { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern bool sRGB { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern float occlusionMaskScale { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern TextureLayout textureLayout { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern TextureLayout supportedTextureLayouts { [MethodImpl(MethodImplOptions.InternalCall)] get; } public extern ReprojectionMode reprojectionMode { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public extern bool disableLegacyRenderer { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public event Action displayFocusChanged; [RequiredByNativeCode] private void InvokeDisplayFocusChanged(bool focus) { if (this.displayFocusChanged != null) { this.displayFocusChanged(focus); } } [MethodImpl(MethodImplOptions.InternalCall)] public extern void MarkTransformLateLatched(Transform transform, LateLatchNode nodeType); public void SetFocusPlane(Vector3 point, Vector3 normal, Vector3 velocity) { SetFocusPlane_Injected(ref point, ref normal, ref velocity); } [MethodImpl(MethodImplOptions.InternalCall)] public extern void SetMSAALevel(int level); [MethodImpl(MethodImplOptions.InternalCall)] public extern int GetRenderPassCount(); public void GetRenderPass(int renderPassIndex, out XRRenderPass renderPass) { if (!Internal_TryGetRenderPass(renderPassIndex, out renderPass)) { throw new IndexOutOfRangeException("renderPassIndex"); } } [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetRenderPass")] private extern bool Internal_TryGetRenderPass(int renderPassIndex, out XRRenderPass renderPass); public void EndRecordingIfLateLatched(Camera camera) { if (!Internal_TryEndRecordingIfLateLatched(camera) && (Object)(object)camera == (Object)null) { throw new ArgumentNullException("camera"); } } [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryEndRecordingIfLateLatched")] private extern bool Internal_TryEndRecordingIfLateLatched(Camera camera); public void BeginRecordingIfLateLatched(Camera camera) { if (!Internal_TryBeginRecordingIfLateLatched(camera) && (Object)(object)camera == (Object)null) { throw new ArgumentNullException("camera"); } } [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryBeginRecordingIfLateLatched")] private extern bool Internal_TryBeginRecordingIfLateLatched(Camera camera); public void GetCullingParameters(Camera camera, int cullingPassIndex, out ScriptableCullingParameters scriptableCullingParameters) { if (!Internal_TryGetCullingParams(camera, cullingPassIndex, out scriptableCullingParameters)) { if ((Object)(object)camera == (Object)null) { throw new ArgumentNullException("camera"); } throw new IndexOutOfRangeException("cullingPassIndex"); } } [MethodImpl(MethodImplOptions.InternalCall)] [NativeHeader("Runtime/Graphics/ScriptableRenderLoop/ScriptableCulling.h")] [NativeMethod("TryGetCullingParams")] private extern bool Internal_TryGetCullingParams(Camera camera, int cullingPassIndex, out ScriptableCullingParameters scriptableCullingParameters); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetAppGPUTimeLastFrame")] public extern bool TryGetAppGPUTimeLastFrame(out float gpuTimeLastFrame); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetCompositorGPUTimeLastFrame")] public extern bool TryGetCompositorGPUTimeLastFrame(out float gpuTimeLastFrameCompositor); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetDroppedFrameCount")] public extern bool TryGetDroppedFrameCount(out int droppedFrameCount); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetFramePresentCount")] public extern bool TryGetFramePresentCount(out int framePresentCount); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetDisplayRefreshRate")] public extern bool TryGetDisplayRefreshRate(out float displayRefreshRate); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetMotionToPhoton")] public extern bool TryGetMotionToPhoton(out float motionToPhoton); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod(Name = "GetTextureForRenderPass", IsThreadSafe = false)] [NativeConditional("ENABLE_XR")] public extern RenderTexture GetRenderTextureForRenderPass(int renderPass); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod(Name = "GetSharedDepthTextureForRenderPass", IsThreadSafe = false)] [NativeConditional("ENABLE_XR")] public extern RenderTexture GetSharedDepthTextureForRenderPass(int renderPass); [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod(Name = "GetPreferredMirrorViewBlitMode", IsThreadSafe = false)] [NativeConditional("ENABLE_XR")] public extern int GetPreferredMirrorBlitMode(); [MethodImpl(MethodImplOptions.InternalCall)] [NativeConditional("ENABLE_XR")] [NativeMethod(Name = "SetPreferredMirrorViewBlitMode", IsThreadSafe = false)] public extern void SetPreferredMirrorBlitMode(int blitMode); [Obsolete("GetMirrorViewBlitDesc(RenderTexture, out XRMirrorViewBlitDesc) is deprecated. Use GetMirrorViewBlitDesc(RenderTexture, out XRMirrorViewBlitDesc, int) instead.", false)] public bool GetMirrorViewBlitDesc(RenderTexture mirrorRt, out XRMirrorViewBlitDesc outDesc) { return GetMirrorViewBlitDesc(mirrorRt, out outDesc, -1); } [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod(Name = "QueryMirrorViewBlitDesc", IsThreadSafe = false)] [NativeConditional("ENABLE_XR")] public extern bool GetMirrorViewBlitDesc(RenderTexture mirrorRt, out XRMirrorViewBlitDesc outDesc, int mode); [Obsolete("AddGraphicsThreadMirrorViewBlit(CommandBuffer, bool) is deprecated. Use AddGraphicsThreadMirrorViewBlit(CommandBuffer, bool, int) instead.", false)] public bool AddGraphicsThreadMirrorViewBlit(CommandBuffer cmd, bool allowGraphicsStateInvalidate) { return AddGraphicsThreadMirrorViewBlit(cmd, allowGraphicsStateInvalidate, -1); } [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod(Name = "AddGraphicsThreadMirrorViewBlit", IsThreadSafe = false)] [NativeHeader("Runtime/Graphics/CommandBuffer/RenderingCommandBuffer.h")] [NativeConditional("ENABLE_XR")] public extern bool AddGraphicsThreadMirrorViewBlit(CommandBuffer cmd, bool allowGraphicsStateInvalidate, int mode); [MethodImpl(MethodImplOptions.InternalCall)] private extern void SetFocusPlane_Injected(ref Vector3 point, ref Vector3 normal, ref Vector3 velocity); } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct XRMirrorViewBlitMode { public const int Default = 0; public const int LeftEye = -1; public const int RightEye = -2; public const int SideBySide = -3; public const int SideBySideOcclusionMesh = -4; public const int Distort = -5; public const int None = -6; } [NativeHeader("Modules/XR/XRPrefix.h")] [NativeType(Header = "Modules/XR/Subsystems/Display/XRDisplaySubsystemDescriptor.h")] public struct XRMirrorViewBlitModeDesc { public int blitMode; public string blitModeDesc; } [UsedByNativeCode] [NativeType(Header = "Modules/XR/Subsystems/Display/XRDisplaySubsystemDescriptor.h")] public class XRDisplaySubsystemDescriptor : IntegratedSubsystemDescriptor { [NativeConditional("ENABLE_XR")] public extern bool disablesLegacyVr { [MethodImpl(MethodImplOptions.InternalCall)] get; } [NativeConditional("ENABLE_XR")] public extern bool enableBackBufferMSAA { [MethodImpl(MethodImplOptions.InternalCall)] get; } [MethodImpl(MethodImplOptions.InternalCall)] [NativeMethod("TryGetAvailableMirrorModeCount")] [NativeConditional("ENABLE_XR")] public extern int GetAvailableMirrorBlitModeCount(); [MethodImpl(MethodImplOptions.InternalCall)] [NativeConditional("ENABLE_XR")] [NativeMethod("TryGetMirrorModeByIndex")] public extern void GetMirrorBlitModeByIndex(int index, out XRMirrorViewBlitModeDesc mode); } public enum TrackingOriginModeFlags { Unknown = 0, Device = 1, Floor = 2, TrackingReference = 4, Unbounded = 8 } [NativeType(Header = "Modules/XR/Subsystems/Input/XRInputSubsystem.h")] [NativeConditional("ENABLE_XR")] [UsedByNativeCode] public class XRInputSubsystem : IntegratedSubsystem { private List m_DeviceIdsCache; public event Action trackingOriginUpdated; public event Action boundaryChanged; [MethodImpl(MethodImplOptions.InternalCall)] internal extern uint GetIndex(); [MethodImpl(MethodImplOptions.InternalCall)] public extern bool TryRecenter(); public bool TryGetInputDevices(List devices) { if (devices == null) { throw new ArgumentNullException("devices"); } devices.Clear(); if (m_DeviceIdsCache == null) { m_DeviceIdsCache = new List(); } m_DeviceIdsCache.Clear(); TryGetDeviceIds_AsList(m_DeviceIdsCache); for (int i = 0; i < m_DeviceIdsCache.Count; i++) { devices.Add(new InputDevice(m_DeviceIdsCache[i])); } return true; } [MethodImpl(MethodImplOptions.InternalCall)] public extern bool TrySetTrackingOriginMode(TrackingOriginModeFlags origin); [MethodImpl(MethodImplOptions.InternalCall)] public extern TrackingOriginModeFlags GetTrackingOriginMode(); [MethodImpl(MethodImplOptions.InternalCall)] public extern TrackingOriginModeFlags GetSupportedTrackingOriginModes(); public bool TryGetBoundaryPoints(List boundaryPoints) { if (boundaryPoints == null) { throw new ArgumentNullException("boundaryPoints"); } return TryGetBoundaryPoints_AsList(boundaryPoints); } [MethodImpl(MethodImplOptions.InternalCall)] private extern bool TryGetBoundaryPoints_AsList(List boundaryPoints); [RequiredByNativeCode(GenerateProxy = true)] private static void InvokeTrackingOriginUpdatedEvent(IntPtr internalPtr) { IntegratedSubsystem integratedSubsystemByPtr = SubsystemManager.GetIntegratedSubsystemByPtr(internalPtr); if (integratedSubsystemByPtr is XRInputSubsystem { trackingOriginUpdated: not null } xRInputSubsystem) { xRInputSubsystem.trackingOriginUpdated(xRInputSubsystem); } } [RequiredByNativeCode(GenerateProxy = true)] private static void InvokeBoundaryChangedEvent(IntPtr internalPtr) { IntegratedSubsystem integratedSubsystemByPtr = SubsystemManager.GetIntegratedSubsystemByPtr(internalPtr); if (integratedSubsystemByPtr is XRInputSubsystem { boundaryChanged: not null } xRInputSubsystem) { xRInputSubsystem.boundaryChanged(xRInputSubsystem); } } [MethodImpl(MethodImplOptions.InternalCall)] internal extern void TryGetDeviceIds_AsList(List deviceIds); } [UsedByNativeCode] [NativeConditional("ENABLE_XR")] [NativeType(Header = "Modules/XR/Subsystems/Input/XRInputSubsystemDescriptor.h")] [NativeHeader("Modules/XR/XRPrefix.h")] public class XRInputSubsystemDescriptor : IntegratedSubsystemDescriptor { [NativeConditional("ENABLE_XR")] public extern bool disablesLegacyInput { [MethodImpl(MethodImplOptions.InternalCall)] get; } } [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] [UsedByNativeCode] public struct MeshId : IEquatable { private static MeshId s_InvalidId = default(MeshId); private ulong m_SubId1; private ulong m_SubId2; public static MeshId InvalidId => s_InvalidId; public override string ToString() { return string.Format("{0}-{1}", m_SubId1.ToString("X16"), m_SubId2.ToString("X16")); } public override int GetHashCode() { return m_SubId1.GetHashCode() ^ m_SubId2.GetHashCode(); } public override bool Equals(object obj) { return obj is MeshId && Equals((MeshId)obj); } public bool Equals(MeshId other) { return m_SubId1 == other.m_SubId1 && m_SubId2 == other.m_SubId2; } public static bool operator ==(MeshId id1, MeshId id2) { return id1.m_SubId1 == id2.m_SubId1 && id1.m_SubId2 == id2.m_SubId2; } public static bool operator !=(MeshId id1, MeshId id2) { return id1.m_SubId1 != id2.m_SubId1 || id1.m_SubId2 != id2.m_SubId2; } } [RequiredByNativeCode] [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] public enum MeshGenerationStatus { Success, InvalidMeshId, GenerationAlreadyInProgress, Canceled, UnknownError } internal static class HashCodeHelper { private const int k_HashCodeMultiplier = 486187739; public static int Combine(int hash1, int hash2) { return hash1 * 486187739 + hash2; } public static int Combine(int hash1, int hash2, int hash3) { return Combine(Combine(hash1, hash2), hash3); } public static int Combine(int hash1, int hash2, int hash3, int hash4) { return Combine(Combine(hash1, hash2, hash3), hash4); } public static int Combine(int hash1, int hash2, int hash3, int hash4, int hash5) { return Combine(Combine(hash1, hash2, hash3, hash4), hash5); } public static int Combine(int hash1, int hash2, int hash3, int hash4, int hash5, int hash6) { return Combine(Combine(hash1, hash2, hash3, hash4, hash5), hash6); } public static int Combine(int hash1, int hash2, int hash3, int hash4, int hash5, int hash6, int hash7) { return Combine(Combine(hash1, hash2, hash3, hash4, hash5, hash6), hash7); } public static int Combine(int hash1, int hash2, int hash3, int hash4, int hash5, int hash6, int hash7, int hash8) { return Combine(Combine(hash1, hash2, hash3, hash4, hash5, hash6, hash7), hash8); } } [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] [RequiredByNativeCode] public struct MeshGenerationResult : IEquatable { public MeshId MeshId { get; } public Mesh Mesh { get; } public MeshCollider MeshCollider { get; } public MeshGenerationStatus Status { get; } public MeshVertexAttributes Attributes { get; } public ulong Timestamp { get; } public Vector3 Position { get; } public Quaternion Rotation { get; } public Vector3 Scale { get; } public override bool Equals(object obj) { if (!(obj is MeshGenerationResult)) { return false; } return Equals((MeshGenerationResult)obj); } public bool Equals(MeshGenerationResult other) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) int result; if (MeshId.Equals(other.MeshId) && ((object)Mesh).Equals((object?)other.Mesh) && ((object)MeshCollider).Equals((object?)other.MeshCollider) && Status == other.Status && Attributes == other.Attributes) { Vector3 val = Position; if (((Vector3)(ref val)).Equals(other.Position)) { Quaternion rotation = Rotation; if (((Quaternion)(ref rotation)).Equals(other.Rotation)) { val = Scale; result = (((Vector3)(ref val)).Equals(other.Scale) ? 1 : 0); goto IL_00a7; } } } result = 0; goto IL_00a7; IL_00a7: return (byte)result != 0; } public static bool operator ==(MeshGenerationResult lhs, MeshGenerationResult rhs) { return lhs.Equals(rhs); } public static bool operator !=(MeshGenerationResult lhs, MeshGenerationResult rhs) { return !lhs.Equals(rhs); } public override int GetHashCode() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) return HashCodeHelper.Combine(MeshId.GetHashCode(), ((object)Mesh).GetHashCode(), ((object)MeshCollider).GetHashCode(), ((int)Status).GetHashCode(), ((int)Attributes).GetHashCode(), ((object)Position/*cast due to .constrained prefix*/).GetHashCode(), ((object)Rotation/*cast due to .constrained prefix*/).GetHashCode(), ((object)Scale/*cast due to .constrained prefix*/).GetHashCode()); } } [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] [UsedByNativeCode] [Flags] public enum MeshVertexAttributes { None = 0, Normals = 1, Tangents = 2, UVs = 4, Colors = 8 } [Flags] [UsedByNativeCode] [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] public enum MeshGenerationOptions { None = 0, ConsumeTransform = 1 } [UsedByNativeCode] [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] public enum MeshChangeState { Added, Updated, Removed, Unchanged } [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] [UsedByNativeCode] public struct MeshInfo : IEquatable { public MeshId MeshId { get; set; } public MeshChangeState ChangeState { get; set; } public int PriorityHint { get; set; } public override bool Equals(object obj) { if (!(obj is MeshInfo)) { return false; } return Equals((MeshInfo)obj); } public bool Equals(MeshInfo other) { return MeshId.Equals(other.MeshId) && ChangeState.Equals(other.ChangeState) && PriorityHint.Equals(other.PriorityHint); } public static bool operator ==(MeshInfo lhs, MeshInfo rhs) { return lhs.Equals(rhs); } public static bool operator !=(MeshInfo lhs, MeshInfo rhs) { return !lhs.Equals(rhs); } public override int GetHashCode() { return HashCodeHelper.Combine(MeshId.GetHashCode(), ((int)ChangeState).GetHashCode(), PriorityHint.GetHashCode()); } } [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshBindings.h")] [UsedByNativeCode] public readonly struct MeshTransform : IEquatable { public MeshId MeshId { get; } public ulong Timestamp { get; } public Vector3 Position { get; } public Quaternion Rotation { get; } public Vector3 Scale { get; } public MeshTransform(in MeshId meshId, ulong timestamp, in Vector3 position, in Quaternion rotation, in Vector3 scale) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) MeshId = meshId; Timestamp = timestamp; Position = position; Rotation = rotation; Scale = scale; } public override bool Equals(object obj) { return obj is MeshTransform other && Equals(other); } public bool Equals(MeshTransform other) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) int result; if (MeshId.Equals(other.MeshId) && Timestamp == other.Timestamp) { Vector3 val = Position; if (((Vector3)(ref val)).Equals(other.Position)) { Quaternion rotation = Rotation; if (((Quaternion)(ref rotation)).Equals(other.Rotation)) { val = Scale; result = (((Vector3)(ref val)).Equals(other.Scale) ? 1 : 0); goto IL_006c; } } } result = 0; goto IL_006c; IL_006c: return (byte)result != 0; } public static bool operator ==(MeshTransform lhs, MeshTransform rhs) { return lhs.Equals(rhs); } public static bool operator !=(MeshTransform lhs, MeshTransform rhs) { return !lhs.Equals(rhs); } public override int GetHashCode() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) return HashCodeHelper.Combine(MeshId.GetHashCode(), Timestamp.GetHashCode(), ((object)Position/*cast due to .constrained prefix*/).GetHashCode(), ((object)Rotation/*cast due to .constrained prefix*/).GetHashCode(), ((object)Scale/*cast due to .constrained prefix*/).GetHashCode()); } } [NativeConditional("ENABLE_XR")] [NativeHeader("Modules/XR/Subsystems/Meshing/XRMeshingSubsystem.h")] [UsedByNativeCode] [NativeHeader("Modules/XR/XRPrefix.h")] public class XRMeshSubsystem : IntegratedSubsystem { [NativeConditional("ENABLE_XR")] private readonly struct MeshTransformList : IDisposable { private readonly IntPtr m_Self; public int Count => GetLength(m_Self); public IntPtr Data => GetData(m_Self); public MeshTransformList(IntPtr self) { m_Self = self; } public void Dispose() { Dispose(m_Self); } [MethodImpl(MethodImplOptions.InternalCall)] [FreeFunction("UnityXRMeshTransformList_get_Length")] private static extern int GetLength(IntPtr self); [MethodImpl(MethodImplOptions.InternalCall)] [FreeFunction("UnityXRMeshTransformList_get_Data")] private static extern IntPtr GetData(IntPtr self); [MethodImpl(MethodImplOptions.InternalCall)] [FreeFunction("UnityXRMeshTransformList_Dispose")] private static extern void Dispose(IntPtr self); } public extern float meshDensity { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; } public bool TryGetMeshInfos(List meshInfosOut) { if (meshInfosOut == null) { throw new ArgumentNullException("meshInfosOut"); } return GetMeshInfosAsList(meshInfosOut); } [MethodImpl(MethodImplOptions.InternalCall)] private extern bool GetMeshInfosAsList(List meshInfos); [MethodImpl(MethodImplOptions.InternalCall)] private extern MeshInfo[] GetMeshInfosAsFixedArray(); public void GenerateMeshAsync(MeshId meshId, Mesh mesh, MeshCollider meshCollider, MeshVertexAttributes attributes, Action onMeshGenerationComplete) { GenerateMeshAsync(meshId, mesh, meshCollider, attributes, onMeshGenerationComplete, MeshGenerationOptions.None); } public void GenerateMeshAsync(MeshId meshId, Mesh mesh, MeshCollider meshCollider, MeshVertexAttributes attributes, Action onMeshGenerationComplete, MeshGenerationOptions options) { GenerateMeshAsync_Injected(ref meshId, mesh, meshCollider, attributes, onMeshGenerationComplete, options); } [RequiredByNativeCode] private void InvokeMeshReadyDelegate(MeshGenerationResult result, Action onMeshGenerationComplete) { onMeshGenerationComplete?.Invoke(result); } public bool SetBoundingVolume(Vector3 origin, Vector3 extents) { return SetBoundingVolume_Injected(ref origin, ref extents); } public unsafe NativeArray GetUpdatedMeshTransforms(Allocator allocator) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) using MeshTransformList meshTransformList = new MeshTransformList(GetUpdatedMeshTransforms()); NativeArray val = new NativeArray(meshTransformList.Count, allocator, (NativeArrayOptions)0); UnsafeUtility.MemCpy(NativeArrayUnsafeUtility.GetUnsafePtr(val), meshTransformList.Data.ToPointer(), (long)(meshTransformList.Count * Unsafe.SizeOf())); return val; } [MethodImpl(MethodImplOptions.InternalCall)] private extern IntPtr GetUpdatedMeshTransforms(); [MethodImpl(MethodImplOptions.InternalCall)] private extern void GenerateMeshAsync_Injected(ref MeshId meshId, Mesh mesh, MeshCollider meshCollider, MeshVertexAttributes attributes, Action onMeshGenerationComplete, MeshGenerationOptions options); [MethodImpl(MethodImplOptions.InternalCall)] private extern bool SetBoundingVolume_Injected(ref Vector3 origin, ref Vector3 extents); } [UsedByNativeCode] [NativeHeader("Modules/XR/XRPrefix.h")] [NativeType(Header = "Modules/XR/Subsystems/Planes/XRMeshSubsystemDescriptor.h")] public class XRMeshSubsystemDescriptor : IntegratedSubsystemDescriptor { } } namespace UnityEngine.XR.Provider { public static class XRStats { public static bool TryGetStat(IntegratedSubsystem xrSubsystem, string tag, out float value) { return TryGetStat_Internal(xrSubsystem.m_Ptr, tag, out value); } [MethodImpl(MethodImplOptions.InternalCall)] [NativeConditional("ENABLE_XR")] [NativeHeader("Modules/XR/Stats/XRStats.h")] [NativeMethod("TryGetStatByName_Internal")] [StaticAccessor(/*Could not decode attribute arguments.*/)] private static extern bool TryGetStat_Internal(IntPtr ptr, string tag, out float value); } }