using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Bhaptics.Tact; using EntityStates; using EntityStates.Bandit2.Weapon; using EntityStates.Captain.Weapon; using EntityStates.Commando; using EntityStates.Commando.CommandoWeapon; using EntityStates.Croco; using EntityStates.Engi.EngiMissilePainter; using EntityStates.Engi.EngiWeapon; using EntityStates.GlobalSkills.LunarNeedle; using EntityStates.Huntress; using EntityStates.Huntress.HuntressWeapon; using EntityStates.LaserTurbine; using EntityStates.Loader; using EntityStates.Mage; using EntityStates.Mage.Weapon; using EntityStates.Merc; using EntityStates.Railgunner.Scope; using EntityStates.Railgunner.Weapon; using EntityStates.Seeker; using EntityStates.Toolbot; using EntityStates.Treebot.Weapon; using EntityStates.VagrantNovaItem; using EntityStates.VoidSurvivor; using EntityStates.VoidSurvivor.Weapon; using HG; using HG.GeneralSerializer; using IL.EntityStates.GlobalSkills.LunarNeedle; using IL.EntityStates.Toolbot; using IL.RoR2; using IL.RoR2.CameraModes; using IL.RoR2.UI; using LIV.SDK.Unity; using LeTai.Asset.TranslucentImage; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On.EntityStates; using On.EntityStates.Bandit2.Weapon; using On.EntityStates.Captain.Weapon; using On.EntityStates.Commando.CommandoWeapon; using On.EntityStates.Croco; using On.EntityStates.Engi.EngiMissilePainter; using On.EntityStates.Engi.EngiWeapon; using On.EntityStates.Huntress; using On.EntityStates.Huntress.HuntressWeapon; using On.EntityStates.LaserTurbine; using On.EntityStates.Loader; using On.EntityStates.Mage.Weapon; using On.EntityStates.Merc; using On.EntityStates.Railgunner.Scope; using On.EntityStates.Railgunner.Weapon; using On.EntityStates.Seeker; using On.EntityStates.Toolbot; using On.EntityStates.Treebot.Weapon; using On.EntityStates.VagrantNovaItem; using On.EntityStates.VoidSurvivor; using On.RoR2; using On.RoR2.CameraModes; using On.RoR2.GamepadVibration; using On.RoR2.Networking; using On.RoR2.Projectile; using On.RoR2.RemoteGameBrowser; using On.RoR2.UI; using On.RoR2.UI.LogBook; using On.RoR2.UI.MainMenu; using Rewired; using Rewired.Data; using Rewired.Data.Mapping; using Rewired.Utils.Classes.Data; using RoR2; using RoR2.CameraModes; using RoR2.GamepadVibration; using RoR2.HudOverlay; using RoR2.Networking; using RoR2.PostProcess; using RoR2.Projectile; using RoR2.RemoteGameBrowser; using RoR2.Skills; using RoR2.UI; using RoR2.UI.LogBook; using RoR2.UI.MainMenu; using TMPro; using ThreeEyedGames; using Unity.XR.CoreUtils; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.Networking; using UnityEngine.Playables; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; using UnityEngine.Serialization; using UnityEngine.SpatialTracking; using UnityEngine.UI; using UnityEngine.XR; using UnityEngine.XR.Interaction.Toolkit; using UnityEngine.XR.Management; using UnityEngine.XR.OpenXR; using UnityEngine.XR.OpenXR.Features; using UnityEngine.XR.OpenXR.Features.Interactions; using VRMod; using VRMod.Haptics; using VRMod.Inputs; using VRMod.Properties; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LIV.SDK.Unity { [Flags] public enum INVALIDATION_FLAGS : uint { NONE = 0u, HMD_CAMERA = 1u, STAGE = 2u, MR_CAMERA_PREFAB = 4u, EXCLUDE_BEHAVIOURS = 8u } [HelpURL("https://liv.tv/sdk-unity-docs")] [AddComponentMenu("LIV/LIV")] public class LIV : MonoBehaviour { public Action onActivate; public Action onPreRender; public Action onPreRenderBackground; public Action onPostRenderBackground; public Action onPreRenderForeground; public Action onPostRenderForeground; public Action onPostRender; public Action onDeactivate; [Tooltip("This is the topmost transform of your VR rig.")] [FormerlySerializedAs("TrackedSpaceOrigin")] [SerializeField] private Transform _stage; [Tooltip("This transform is an additional wrapper to the user’s playspace.")] [FormerlySerializedAs("StageTransform")] [SerializeField] private Transform _stageTransform; [Tooltip("This is the camera responsible for rendering the user’s HMD.")] [FormerlySerializedAs("HMDCamera")] [SerializeField] private Camera _HMDCamera; [Tooltip("Camera prefab for customized rendering.")] [FormerlySerializedAs("MRCameraPrefab")] [SerializeField] private Camera _MRCameraPrefab; [Tooltip("This option disables all standard Unity assets for the Mixed Reality rendering.")] [FormerlySerializedAs("DisableStandardAssets")] [SerializeField] private bool _disableStandardAssets; [Tooltip("The layer mask defines exactly which object layers should be rendered in MR.")] [FormerlySerializedAs("SpectatorLayerMask")] [SerializeField] private LayerMask _spectatorLayerMask = LayerMask.op_Implicit(-1); [Tooltip("This is for removing unwanted scripts from the cloned MR camera.")] [FormerlySerializedAs("ExcludeBehaviours")] [SerializeField] private string[] _excludeBehaviours = new string[5] { "AudioListener", "Collider", "SteamVR_Camera", "SteamVR_Fade", "SteamVR_ExternalCamera" }; [Tooltip("Recovers corrupted alpha channel when using post-effects.")] [FormerlySerializedAs("FixPostEffectsAlpha")] [SerializeField] private bool _fixPostEffectsAlpha; private bool _isActive; private SDKRender _render; private bool _wasReady; private INVALIDATION_FLAGS _invalidate; private Transform _stageCandidate; private Camera _HMDCameraCandidate; private Camera _MRCameraPrefabCandidate; private string[] _excludeBehavioursCandidate; private bool _enabled; private Coroutine _waitForEndOfFrameCoroutine; public Transform stage { get { if (!((Object)(object)_stage == (Object)null)) { return _stage; } return ((Component)this).transform.parent; } set { if ((Object)(object)value == (Object)null) { Debug.LogWarning((object)"LIV: Stage cannot be null!"); } if ((Object)(object)_stage != (Object)(object)value) { _stageCandidate = value; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 2uL, enabled: true); } } } [Obsolete("Use stage instead")] public Transform trackedSpaceOrigin { get { return stage; } set { stage = value; } } public Matrix4x4 stageLocalToWorldMatrix { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)stage != (Object)null)) { return Matrix4x4.identity; } return stage.localToWorldMatrix; } } public Matrix4x4 stageWorldToLocalMatrix { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)stage != (Object)null)) { return Matrix4x4.identity; } return stage.worldToLocalMatrix; } } public Transform stageTransform { get { return _stageTransform; } set { _stageTransform = value; } } public Camera HMDCamera { get { return _HMDCamera; } set { if ((Object)(object)value == (Object)null) { Debug.LogWarning((object)"LIV: HMD Camera cannot be null!"); } if ((Object)(object)_HMDCamera != (Object)(object)value) { _HMDCameraCandidate = value; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 1uL, enabled: true); } } } public Camera MRCameraPrefab { get { return _MRCameraPrefab; } set { if ((Object)(object)_MRCameraPrefab != (Object)(object)value) { _MRCameraPrefabCandidate = value; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 4uL, enabled: true); } } } public bool disableStandardAssets { get { return _disableStandardAssets; } set { _disableStandardAssets = value; } } public LayerMask spectatorLayerMask { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _spectatorLayerMask; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _spectatorLayerMask = value; } } public string[] excludeBehaviours { get { return _excludeBehaviours; } set { if (_excludeBehaviours != value) { _excludeBehavioursCandidate = value; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 8uL, enabled: true); } } } public bool fixPostEffectsAlpha { get { return _fixPostEffectsAlpha; } set { _fixPostEffectsAlpha = value; } } public bool isValid { get { if (_invalidate != INVALIDATION_FLAGS.NONE) { return false; } if ((Object)(object)_HMDCamera == (Object)null) { return false; } return true; } } public bool isActive => _isActive; private bool _isReady { get { if (isValid && _enabled) { return SDKBridge.IsActive; } return false; } } public SDKRender render => _render; private void Awake() { ((Behaviour)this).enabled = false; } private void OnEnable() { _enabled = true; UpdateSDKReady(); } private void Update() { UpdateSDKReady(); Invalidate(); } private void OnDisable() { _enabled = false; UpdateSDKReady(); } private IEnumerator WaitForUnityEndOfFrame() { while (Application.isPlaying && ((Behaviour)this).enabled) { yield return (object)new WaitForEndOfFrame(); if (isActive) { _render.Render(); } } } private void UpdateSDKReady() { bool isReady = _isReady; if (isReady != _wasReady) { OnSDKReadyChanged(isReady); _wasReady = isReady; } } private void OnSDKReadyChanged(bool value) { if (value) { OnSDKActivate(); } else { OnSDKDeactivate(); } } private void OnSDKActivate() { Debug.Log((object)"LIV: Compositor connected, setting up Mixed Reality!"); SubmitSDKOutput(); CreateAssets(); StartRenderCoroutine(); _isActive = true; if (onActivate != null) { onActivate(); } } private void OnSDKDeactivate() { Debug.Log((object)"LIV: Compositor disconnected, cleaning up Mixed Reality."); if (onDeactivate != null) { onDeactivate(); } StopRenderCoroutine(); DestroyAssets(); _isActive = false; if (Object.op_Implicit((Object)(object)UIFixes.livHUD)) { Object.Destroy((Object)(object)((Component)UIFixes.livHUD).gameObject); } } private void CreateAssets() { DestroyAssets(); _render = new SDKRender(this); if (ModConfig.LIVHUD.Value) { UIFixes.CreateLIVHUD(_render.uiCameraInstance); } } private void DestroyAssets() { if (_render != null) { _render.Dispose(); _render = null; } } private void StartRenderCoroutine() { StopRenderCoroutine(); _waitForEndOfFrameCoroutine = ((MonoBehaviour)this).StartCoroutine(WaitForUnityEndOfFrame()); } private void StopRenderCoroutine() { if (_waitForEndOfFrameCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_waitForEndOfFrameCoroutine); _waitForEndOfFrameCoroutine = null; } } private void SubmitSDKOutput() { //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) SDKApplicationOutput empty = SDKApplicationOutput.empty; empty.supportedFeatures = FEATURES.BACKGROUND_RENDER | FEATURES.FOREGROUND_RENDER | FEATURES.OVERRIDE_POST_PROCESSING | FEATURES.FIX_FOREGROUND_ALPHA; empty.sdkID = "UT4QDBPGHQZHTDVOSRUHN1PZZCM187WV"; empty.sdkVersion = "1.5.4"; empty.engineName = "unity"; empty.engineVersion = Application.unityVersion; empty.applicationName = Application.productName; empty.applicationVersion = Application.version; empty.graphicsAPI = ((object)SystemInfo.graphicsDeviceType/*cast due to .constrained prefix*/).ToString(); empty.xrDeviceName = XRSettings.loadedDeviceName; SDKBridge.SubmitApplicationOutput(empty); } private void Invalidate() { if (SDKUtils.ContainsFlag((ulong)_invalidate, 2uL)) { _stage = _stageCandidate; _stageCandidate = null; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 2uL, enabled: false); } if (SDKUtils.ContainsFlag((ulong)_invalidate, 1uL)) { _HMDCamera = _HMDCameraCandidate; _HMDCameraCandidate = null; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 1uL, enabled: false); } if (SDKUtils.ContainsFlag((ulong)_invalidate, 4uL)) { _MRCameraPrefab = _MRCameraPrefabCandidate; _MRCameraPrefabCandidate = null; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 4uL, enabled: false); } if (SDKUtils.ContainsFlag((ulong)_invalidate, 8uL)) { _excludeBehaviours = _excludeBehavioursCandidate; _excludeBehavioursCandidate = null; _invalidate = (INVALIDATION_FLAGS)SDKUtils.SetFlag((ulong)_invalidate, 8uL, enabled: false); } } } public static class SDKBridge { public struct SDKInjection { public bool active; public Action action; public T data; } private static SDKInjection _injection_SDKInputFrame = new SDKInjection { active = false, action = null, data = SDKInputFrame.empty }; private static SDKInjection _injection_SDKResolution = new SDKInjection { active = false, action = null, data = SDKResolution.zero }; private static SDKInjection _injection_IsActive = new SDKInjection { active = false, action = null, data = false }; private static bool _injection_DisableSubmit = false; private static bool _injection_DisableSubmitApplicationOutput = false; private static bool _injection_DisableAddTexture = false; private static bool _injection_DisableCreateFrame = false; public static bool IsActive { get { if (_injection_IsActive.active) { return _injection_IsActive.data; } return GetIsCaptureActive(); } } [DllImport("LIV_Bridge")] private static extern IntPtr GetRenderEventFunc(); [DllImport("LIV_Bridge", EntryPoint = "LivCaptureIsActive")] [return: MarshalAs(UnmanagedType.U1)] private static extern bool GetIsCaptureActive(); [DllImport("LIV_Bridge", EntryPoint = "LivCaptureWidth")] private static extern int GetTextureWidth(); [DllImport("LIV_Bridge", EntryPoint = "LivCaptureHeight")] private static extern int GetTextureHeight(); [DllImport("LIV_Bridge", EntryPoint = "LivCaptureSetTextureFromUnity")] private static extern void SetTexture(IntPtr texture); [DllImport("LIV_Bridge")] public static extern int AcquireCompositorFrame(ulong timestamp); [DllImport("LIV_Bridge")] public static extern int ReleaseCompositorFrame(); [DllImport("LIV_Bridge")] public static extern ulong GetObjectTimeStamp(IntPtr obj); [DllImport("LIV_Bridge")] private static extern ulong GetCurrentTimeTicks(); [DllImport("LIV_Bridge")] public static extern ulong GetObjectTag(IntPtr obj); [DllImport("LIV_Bridge")] public static extern IntPtr GetCompositorFrameObject(ulong tag); [DllImport("LIV_Bridge")] public static extern IntPtr GetViewportTexture(); [DllImport("LIV_Bridge")] public static extern IntPtr GetCompositorChannelObject(int slot, ulong tag, ulong timestamp); [DllImport("LIV_Bridge")] public static extern IntPtr GetChannelObject(int slot, ulong tag, ulong timestamp); [DllImport("LIV_Bridge")] public static extern int AddObjectToChannel(int slot, IntPtr obj, int objectsize, ulong tag); [DllImport("LIV_Bridge")] public static extern int AddObjectToCompositorChannel(int slot, IntPtr obj, int objectsize, ulong tag); [DllImport("LIV_Bridge")] public static extern int AddObjectToFrame(IntPtr obj, int objectsize, ulong tag); [DllImport("LIV_Bridge", EntryPoint = "AddObjectToFrame")] public static extern int AddStringToFrame(IntPtr str, ulong tag); [DllImport("LIV_Bridge")] public static extern int AddStringToChannel(int slot, IntPtr str, int length, ulong tag); [DllImport("LIV_Bridge")] public static extern int NewFrame(); [DllImport("LIV_Bridge")] public static extern IntPtr CommitFrame(); [DllImport("LIV_Bridge")] public static extern int addsharedtexture(int width, int height, int format, IntPtr sourcetexture, ulong tag); [DllImport("LIV_Bridge")] public static extern int addtexture(IntPtr sourcetexture, ulong tag); [DllImport("LIV_Bridge")] public static extern void PublishTextures(); [DllImport("LIV_Bridge", EntryPoint = "updateinputframe")] public static extern IntPtr updatinputframe(IntPtr InputFrame); [DllImport("LIV_Bridge")] public static extern IntPtr setinputframe(float x, float y, float z, float q0, float q1, float q2, float q3, float fov, int priority); [DllImport("LIV_Bridge")] public static extern ulong setfeature(ulong feature); [DllImport("LIV_Bridge")] public static extern ulong clearfeature(ulong feature); public static ulong Tag(string str) { ulong num = 0uL; for (int i = 0; i < str.Length && i != 8; i++) { char c = str[i]; num |= (ulong)((long)(c & 0xFF) << i * 8); } return num; } public static void AddString(string tag, string value, int slot) { byte[] bytes = Encoding.UTF8.GetBytes(value); GCHandle gCHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned); AddStringToChannel(slot, Marshal.UnsafeAddrOfPinnedArrayElement(bytes, 0), bytes.Length, Tag(tag)); gCHandle.Free(); } public static void AddTexture(SDKTexture texture, ulong tag) { GCHandle gCHandle = GCHandle.Alloc(texture, GCHandleType.Pinned); addtexture(gCHandle.AddrOfPinnedObject(), tag); gCHandle.Free(); } public static ulong GetObjectTime(IntPtr objectptr) { return GetObjectTimeStamp(objectptr) + 621355968000000000L; } public static ulong GetCurrentTime() { return GetCurrentTimeTicks() + 621355968000000000L; } public static void IssuePluginEvent() { if (!_injection_DisableSubmit) { GL.IssuePluginEvent(GetRenderEventFunc(), 2); } } public static void SubmitApplicationOutput(SDKApplicationOutput applicationOutput) { if (!_injection_DisableSubmitApplicationOutput) { AddString("APPNAME", applicationOutput.applicationName, 5); AddString("APPVER", applicationOutput.applicationVersion, 5); AddString("ENGNAME", applicationOutput.engineName, 5); AddString("ENGVER", applicationOutput.engineVersion, 5); AddString("GFXAPI", applicationOutput.graphicsAPI, 5); AddString("SDKID", applicationOutput.sdkID, 5); AddString("SDKVER", applicationOutput.sdkVersion, 5); AddString("SUPPORT", applicationOutput.supportedFeatures.ToString(), 5); AddString("XRNAME", applicationOutput.xrDeviceName, 5); } } public static bool GetStructFromGlobalChannel(ref T mystruct, int channel, ulong tag) { IntPtr compositorChannelObject = GetCompositorChannelObject(channel, tag, ulong.MaxValue); if (compositorChannelObject == IntPtr.Zero) { return false; } mystruct = (T)Marshal.PtrToStructure(compositorChannelObject, typeof(T)); return true; } public static int AddStructToGlobalChannel(ref T mystruct, int channel, ulong tag) { GCHandle gCHandle = GCHandle.Alloc(mystruct, GCHandleType.Pinned); int result = AddObjectToCompositorChannel(channel, gCHandle.AddrOfPinnedObject(), Marshal.SizeOf(mystruct), tag); gCHandle.Free(); return result; } public static bool GetStructFromLocalChannel(ref T mystruct, int channel, ulong tag) { IntPtr channelObject = GetChannelObject(channel, tag, ulong.MaxValue); if (channelObject == IntPtr.Zero) { return false; } mystruct = (T)Marshal.PtrToStructure(channelObject, typeof(T)); return true; } public static int AddStructToLocalChannel(ref T mystruct, int channel, ulong tag) { GCHandle gCHandle = GCHandle.Alloc(mystruct, GCHandleType.Pinned); int result = AddObjectToChannel(channel, gCHandle.AddrOfPinnedObject(), Marshal.SizeOf(mystruct), tag); gCHandle.Free(); return result; } public static void AddStructToFrame(ref T mystruct, ulong tag) { GCHandle gCHandle = GCHandle.Alloc(mystruct, GCHandleType.Pinned); AddObjectToFrame(gCHandle.AddrOfPinnedObject(), Marshal.SizeOf(mystruct), tag); gCHandle.Free(); } public static bool UpdateInputFrame(ref SDKInputFrame setframe) { if (_injection_SDKInputFrame.active && _injection_SDKInputFrame.action != null) { _injection_SDKInputFrame.action(); setframe = _injection_SDKInputFrame.data; } else { GCHandle gCHandle = GCHandle.Alloc(setframe, GCHandleType.Pinned); IntPtr intPtr = updatinputframe(gCHandle.AddrOfPinnedObject()); gCHandle.Free(); if (intPtr == IntPtr.Zero) { setframe = SDKInputFrame.empty; return false; } setframe = (SDKInputFrame)Marshal.PtrToStructure(intPtr, typeof(SDKInputFrame)); _injection_SDKInputFrame.data = setframe; } return true; } public static SDKTexture GetViewfinderTexture() { _ = SDKTexture.empty; IntPtr compositorChannelObject = GetCompositorChannelObject(11, Tag("OUTTEX"), ulong.MaxValue); if (compositorChannelObject == IntPtr.Zero) { return default(SDKTexture); } return (SDKTexture)Marshal.PtrToStructure(compositorChannelObject, typeof(SDKTexture)); } public static void AddTexture(SDKTexture texture) { if (!_injection_DisableAddTexture) { string str = ""; switch (texture.id) { case TEXTURE_ID.BACKGROUND_COLOR_BUFFER_ID: str = "BGCTEX"; break; case TEXTURE_ID.FOREGROUND_COLOR_BUFFER_ID: str = "FGCTEX"; break; case TEXTURE_ID.OPTIMIZED_COLOR_BUFFER_ID: str = "OPTTEX"; break; } AddTexture(texture, Tag(str)); } } public static void CreateFrame(SDKOutputFrame frame) { if (!_injection_DisableCreateFrame) { GCHandle gCHandle = GCHandle.Alloc(frame, GCHandleType.Pinned); AddObjectToFrame(gCHandle.AddrOfPinnedObject(), Marshal.SizeOf(frame), Tag("OUTFRAME")); gCHandle.Free(); } } public static void SetGroundPlane(SDKPlane groundPlane) { AddStructToGlobalChannel(ref groundPlane, 2, Tag("SetGND")); } public static bool GetResolution(ref SDKResolution sdkResolution) { if (_injection_SDKResolution.active && _injection_SDKResolution.action != null) { _injection_SDKResolution.action(); sdkResolution = _injection_SDKResolution.data; return true; } bool structFromLocalChannel = GetStructFromLocalChannel(ref sdkResolution, 15, Tag("SDKRes")); _injection_SDKResolution.data = sdkResolution; return structFromLocalChannel; } } public class SDKRender : IDisposable { private CommandBuffer _clipPlaneCommandBuffer; private CommandBuffer _combineAlphaCommandBuffer; private CommandBuffer _captureTextureCommandBuffer; private CommandBuffer _applyTextureCommandBuffer; private CommandBuffer _optimizedRenderingCommandBuffer; private CameraEvent _clipPlaneCameraEvent = (CameraEvent)11; private CameraEvent _clipPlaneCombineAlphaCameraEvent = (CameraEvent)20; private CameraEvent _captureTextureEvent = (CameraEvent)18; private CameraEvent _applyTextureEvent = (CameraEvent)20; private CameraEvent _optimizedRenderingCameraEvent = (CameraEvent)20; private Mesh _clipPlaneMesh; private Material _clipPlaneSimpleMaterial; private Material _clipPlaneSimpleDebugMaterial; private Material _clipPlaneComplexMaterial; private Material _clipPlaneComplexDebugMaterial; private Material _writeOpaqueToAlphaMaterial; private Material _combineAlphaMaterial; private Material _writeMaterial; private Material _forceForwardRenderingMaterial; private Material _uiTransparentMaterial; private RenderTexture _backgroundRenderTexture; private RenderTexture _uiRenderTexture; private RenderTexture _foregroundRenderTexture; private RenderTexture _optimizedRenderTexture; private RenderTexture _complexClipPlaneRenderTexture; private bool uiRendered; private LIV _liv; private SDKOutputFrame _outputFrame = SDKOutputFrame.empty; private SDKInputFrame _inputFrame = SDKInputFrame.empty; private SDKResolution _resolution = SDKResolution.zero; private Camera _cameraInstance; private Camera _uiCameraInstance; private PostProcessLayer _cameraPostProcess; private SDKPose _requestedPose = SDKPose.empty; private int _requestedPoseFrameIndex; private bool useDeferredRendering { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((int)_cameraInstance.actualRenderingPath != 2) { return (int)_cameraInstance.actualRenderingPath == 3; } return true; } } private bool interlacedRendering => SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.INTERLACED_RENDER); private bool canRenderBackground { get { if (interlacedRendering && Time.frameCount % 2 != 0) { return false; } if (SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.BACKGROUND_RENDER)) { return (Object)(object)_backgroundRenderTexture != (Object)null; } return false; } } private bool canRenderForeground { get { if (interlacedRendering && Time.frameCount % 2 != 1) { return false; } if (SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.FOREGROUND_RENDER)) { return (Object)(object)_foregroundRenderTexture != (Object)null; } return false; } } private bool canRenderOptimized { get { if (SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.OPTIMIZED_RENDER)) { return (Object)(object)_optimizedRenderTexture != (Object)null; } return false; } } public LIV liv => _liv; public SDKOutputFrame outputFrame => _outputFrame; public SDKInputFrame inputFrame => _inputFrame; public SDKResolution resolution => _resolution; public Camera cameraInstance => _cameraInstance; public Camera uiCameraInstance => _uiCameraInstance; public PostProcessLayer cameraPostProcess => _cameraPostProcess; public Camera cameraReference { get { if (!((Object)(object)_liv.MRCameraPrefab == (Object)null)) { return _liv.MRCameraPrefab; } return _liv.HMDCamera; } } public Camera hmdCamera => _liv.HMDCamera; public Transform stage => _liv.stage; public Transform stageTransform => _liv.stageTransform; public Matrix4x4 stageLocalToWorldMatrix { get { //IL_0024: 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) if (!((Object)(object)_liv.stage == (Object)null)) { return _liv.stage.localToWorldMatrix; } return Matrix4x4.identity; } } public Matrix4x4 localToWorldMatrix { get { //IL_0025: 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) if (!((Object)(object)_liv.stageTransform == (Object)null)) { return _liv.stageTransform.localToWorldMatrix; } return stageLocalToWorldMatrix; } } public int spectatorLayerMask => LayerMask.op_Implicit(_liv.spectatorLayerMask); public bool disableStandardAssets => _liv.disableStandardAssets; public bool canSetPose { get { if (_inputFrame.frameid == 0L) { return false; } return _inputFrame.priority.pose <= 63; } } private Material GetClipPlaneMaterial(bool debugClipPlane, bool complexClipPlane, ColorWriteMask colorWriteMask) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected I4, but got Unknown Material val; if (complexClipPlane) { val = (debugClipPlane ? _clipPlaneComplexDebugMaterial : _clipPlaneComplexMaterial); val.SetTexture(SDKShaders.LIV_CLIP_PLANE_HEIGHT_MAP_PROPERTY, (Texture)(object)_complexClipPlaneRenderTexture); val.SetFloat(SDKShaders.LIV_TESSELLATION_PROPERTY, _inputFrame.clipPlane.tesselation); } else { val = (debugClipPlane ? _clipPlaneSimpleDebugMaterial : _clipPlaneSimpleMaterial); } val.SetInt(SDKShaders.LIV_COLOR_MASK, (int)colorWriteMask); return val; } private Material GetGroundClipPlaneMaterial(bool debugClipPlane, ColorWriteMask colorWriteMask) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown Material obj = (debugClipPlane ? _clipPlaneSimpleDebugMaterial : _clipPlaneSimpleMaterial); obj.SetInt(SDKShaders.LIV_COLOR_MASK, (int)colorWriteMask); return obj; } public SDKRender(LIV liv) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //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) _liv = liv; CreateAssets(); } public void Render() { UpdateBridgeResolution(); UpdateBridgeInputFrame(); SDKUtils.ApplyUserSpaceTransform(this); UpdateTextures(); InvokePreRender(); RenderUI(); if (canRenderBackground) { RenderBackground(); } if (canRenderForeground) { RenderForeground(); } if (canRenderOptimized) { RenderOptimized(); } IvokePostRender(); SDKUtils.CreateBridgeOutputFrame(this); SDKBridge.IssuePluginEvent(); } private void RenderUI() { uiRendered = false; if (Object.op_Implicit((Object)(object)_uiCameraInstance) && Object.op_Implicit((Object)(object)_uiRenderTexture)) { _uiCameraInstance.targetTexture = _uiRenderTexture; _uiCameraInstance.Render(); uiRendered = true; _uiCameraInstance.targetTexture = null; _uiTransparentMaterial.mainTexture = (Texture)(object)_uiRenderTexture; } } private void RenderBackground() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) SDKUtils.SetCamera(_cameraInstance, ((Component)_cameraInstance).transform, _inputFrame, localToWorldMatrix, spectatorLayerMask); _cameraInstance.targetTexture = _backgroundRenderTexture; RenderTexture val = null; bool num = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.OVERRIDE_POST_PROCESSING); if (num) { val = RenderTexture.GetTemporary(((Texture)_backgroundRenderTexture).width, ((Texture)_backgroundRenderTexture).height, 0, _backgroundRenderTexture.format); _captureTextureCommandBuffer.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), RenderTargetIdentifier.op_Implicit((Texture)(object)val)); _applyTextureCommandBuffer.Blit((Texture)(object)val, RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1)); _cameraInstance.AddCommandBuffer(_captureTextureEvent, _captureTextureCommandBuffer); _cameraInstance.AddCommandBuffer(_applyTextureEvent, _applyTextureCommandBuffer); } SDKShaders.StartRendering(); SDKShaders.StartBackgroundRendering(); InvokePreRenderBackground(); SendTextureToBridge(_backgroundRenderTexture, TEXTURE_ID.BACKGROUND_COLOR_BUFFER_ID); _cameraInstance.Render(); if (uiRendered) { Graphics.Blit((Texture)(object)_uiRenderTexture, _backgroundRenderTexture, _uiTransparentMaterial); } InvokePostRenderBackground(); _cameraInstance.targetTexture = null; SDKShaders.StopBackgroundRendering(); SDKShaders.StopRendering(); if (num) { _cameraInstance.RemoveCommandBuffer(_captureTextureEvent, _captureTextureCommandBuffer); _cameraInstance.RemoveCommandBuffer(_applyTextureEvent, _applyTextureCommandBuffer); _captureTextureCommandBuffer.Clear(); _applyTextureCommandBuffer.Clear(); RenderTexture.ReleaseTemporary(val); } } private void RenderForeground() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) bool debugClipPlane = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.DEBUG_CLIP_PLANE); bool complexClipPlane = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.COMPLEX_CLIP_PLANE); bool num = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.GROUND_CLIP_PLANE); bool flag = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.OVERRIDE_POST_PROCESSING); bool flag2 = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.FIX_FOREGROUND_ALPHA) | _liv.fixPostEffectsAlpha; if (Object.op_Implicit((Object)(object)_cameraPostProcess)) { ((Behaviour)_cameraPostProcess).enabled = false; } MonoBehaviour[] behaviours = null; bool[] wasBehaviourEnabled = null; if (disableStandardAssets) { SDKUtils.DisableStandardAssets(_cameraInstance, ref behaviours, ref wasBehaviourEnabled); } CameraClearFlags clearFlags = _cameraInstance.clearFlags; Color backgroundColor = _cameraInstance.backgroundColor; Color fogColor = RenderSettings.fogColor; RenderSettings.fogColor = new Color(fogColor.r, fogColor.g, fogColor.b, 0f); SDKUtils.SetCamera(_cameraInstance, ((Component)_cameraInstance).transform, _inputFrame, localToWorldMatrix, spectatorLayerMask); _cameraInstance.clearFlags = (CameraClearFlags)2; _cameraInstance.backgroundColor = Color.clear; _cameraInstance.targetTexture = _foregroundRenderTexture; RenderTexture temporary = RenderTexture.GetTemporary(((Texture)_foregroundRenderTexture).width, ((Texture)_foregroundRenderTexture).height, 0, _foregroundRenderTexture.format); _clipPlaneCommandBuffer.DrawMesh(_clipPlaneMesh, Matrix4x4.identity, _writeOpaqueToAlphaMaterial, 0, 0); Matrix4x4 val = localToWorldMatrix * (Matrix4x4)_inputFrame.clipPlane.transform; _clipPlaneCommandBuffer.DrawMesh(_clipPlaneMesh, val, GetClipPlaneMaterial(debugClipPlane, complexClipPlane, (ColorWriteMask)15), 0, 0); if (num) { Matrix4x4 val2 = localToWorldMatrix * (Matrix4x4)_inputFrame.groundClipPlane.transform; _clipPlaneCommandBuffer.DrawMesh(_clipPlaneMesh, val2, GetGroundClipPlaneMaterial(debugClipPlane, (ColorWriteMask)15), 0, 0); } _clipPlaneCommandBuffer.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), RenderTargetIdentifier.op_Implicit((Texture)(object)temporary)); _cameraInstance.AddCommandBuffer(_clipPlaneCameraEvent, _clipPlaneCommandBuffer); RenderTexture val3 = null; if (flag || flag2) { val3 = RenderTexture.GetTemporary(((Texture)_foregroundRenderTexture).width, ((Texture)_foregroundRenderTexture).height, 0, _foregroundRenderTexture.format); _captureTextureCommandBuffer.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), RenderTargetIdentifier.op_Implicit((Texture)(object)val3)); _cameraInstance.AddCommandBuffer(_captureTextureEvent, _captureTextureCommandBuffer); _writeMaterial.SetInt(SDKShaders.LIV_COLOR_MASK, (!flag) ? 1 : 15); _applyTextureCommandBuffer.Blit((Texture)(object)val3, RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), _writeMaterial); _cameraInstance.AddCommandBuffer(_applyTextureEvent, _applyTextureCommandBuffer); } _combineAlphaMaterial.SetInt(SDKShaders.LIV_COLOR_MASK, 1); _combineAlphaCommandBuffer.Blit((Texture)(object)temporary, RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), _combineAlphaMaterial); _cameraInstance.AddCommandBuffer(_clipPlaneCombineAlphaCameraEvent, _combineAlphaCommandBuffer); if (useDeferredRendering) { SDKUtils.ForceForwardRendering(cameraInstance, _clipPlaneMesh, _forceForwardRenderingMaterial); } SDKShaders.StartRendering(); SDKShaders.StartForegroundRendering(); InvokePreRenderForeground(); SendTextureToBridge(_foregroundRenderTexture, TEXTURE_ID.FOREGROUND_COLOR_BUFFER_ID); _cameraInstance.Render(); if (uiRendered) { Graphics.Blit((Texture)(object)_uiRenderTexture, _foregroundRenderTexture, _uiTransparentMaterial); } InvokePostRenderForeground(); _cameraInstance.targetTexture = null; SDKShaders.StopForegroundRendering(); SDKShaders.StopRendering(); if (flag || flag2) { _cameraInstance.RemoveCommandBuffer(_captureTextureEvent, _captureTextureCommandBuffer); _cameraInstance.RemoveCommandBuffer(_applyTextureEvent, _applyTextureCommandBuffer); _captureTextureCommandBuffer.Clear(); _applyTextureCommandBuffer.Clear(); RenderTexture.ReleaseTemporary(val3); } _cameraInstance.RemoveCommandBuffer(_clipPlaneCameraEvent, _clipPlaneCommandBuffer); _cameraInstance.RemoveCommandBuffer(_clipPlaneCombineAlphaCameraEvent, _combineAlphaCommandBuffer); RenderTexture.ReleaseTemporary(temporary); _clipPlaneCommandBuffer.Clear(); _combineAlphaCommandBuffer.Clear(); _cameraInstance.clearFlags = clearFlags; _cameraInstance.backgroundColor = backgroundColor; RenderSettings.fogColor = fogColor; SDKUtils.RestoreStandardAssets(ref behaviours, ref wasBehaviourEnabled); if (Object.op_Implicit((Object)(object)_cameraPostProcess)) { ((Behaviour)_cameraPostProcess).enabled = true; } } private void RenderOptimized() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) bool debugClipPlane = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.DEBUG_CLIP_PLANE); bool complexClipPlane = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.COMPLEX_CLIP_PLANE); bool num = SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.GROUND_CLIP_PLANE); SDKUtils.SetCamera(_cameraInstance, ((Component)_cameraInstance).transform, _inputFrame, localToWorldMatrix, spectatorLayerMask); _cameraInstance.targetTexture = _optimizedRenderTexture; _writeMaterial.SetInt(SDKShaders.LIV_COLOR_MASK, 1); _optimizedRenderingCommandBuffer.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)0), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), _writeMaterial); _writeOpaqueToAlphaMaterial.SetInt(SDKShaders.LIV_COLOR_MASK, 1); _optimizedRenderingCommandBuffer.DrawMesh(_clipPlaneMesh, Matrix4x4.identity, _writeOpaqueToAlphaMaterial, 0, 0); Matrix4x4 val = localToWorldMatrix * (Matrix4x4)_inputFrame.clipPlane.transform; _optimizedRenderingCommandBuffer.DrawMesh(_clipPlaneMesh, val, GetClipPlaneMaterial(debugClipPlane, complexClipPlane, (ColorWriteMask)1), 0, 0); if (num) { Matrix4x4 val2 = localToWorldMatrix * (Matrix4x4)_inputFrame.groundClipPlane.transform; _optimizedRenderingCommandBuffer.DrawMesh(_clipPlaneMesh, val2, GetGroundClipPlaneMaterial(debugClipPlane, (ColorWriteMask)1), 0, 0); } _cameraInstance.AddCommandBuffer((CameraEvent)20, _optimizedRenderingCommandBuffer); SDKShaders.StartRendering(); SDKShaders.StartBackgroundRendering(); InvokePreRenderBackground(); SendTextureToBridge(_optimizedRenderTexture, TEXTURE_ID.OPTIMIZED_COLOR_BUFFER_ID); _cameraInstance.Render(); if (uiRendered) { Graphics.Blit((Texture)(object)_uiRenderTexture, _backgroundRenderTexture, _uiTransparentMaterial); } InvokePostRenderBackground(); _cameraInstance.targetTexture = null; SDKShaders.StopBackgroundRendering(); SDKShaders.StopRendering(); _cameraInstance.RemoveCommandBuffer((CameraEvent)20, _optimizedRenderingCommandBuffer); _optimizedRenderingCommandBuffer.Clear(); } private void CreateAssets() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Expected O, but got Unknown //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) bool enabled = ((Behaviour)cameraReference).enabled; if (enabled) { ((Behaviour)cameraReference).enabled = false; } bool activeSelf = ((Component)cameraReference).gameObject.activeSelf; if (activeSelf) { ((Component)cameraReference).gameObject.SetActive(false); } GameObject val = Object.Instantiate(((Component)cameraReference).gameObject, _liv.stage); _cameraInstance = (Camera)val.GetComponent("Camera"); SDKUtils.CleanCameraBehaviours(_cameraInstance, _liv.excludeBehaviours); if (activeSelf != ((Component)cameraReference).gameObject.activeSelf) { ((Component)cameraReference).gameObject.SetActive(activeSelf); } if (enabled != ((Behaviour)cameraReference).enabled) { ((Behaviour)cameraReference).enabled = enabled; } ((Object)_cameraInstance).name = "LIV Camera"; if (((Component)_cameraInstance).tag == "MainCamera") { ((Component)_cameraInstance).tag = "Untagged"; } ((Component)_cameraInstance).transform.localScale = Vector3.one; _cameraInstance.rect = new Rect(0f, 0f, 1f, 1f); _cameraInstance.depth = 0f; _cameraInstance.stereoTargetEye = (StereoTargetEyeMask)0; _cameraInstance.allowMSAA = false; ((Behaviour)_cameraInstance).enabled = false; ((Component)_cameraInstance).gameObject.SetActive(true); ((Component)_cameraInstance).GetComponent().cameraRigController = ((Component)cameraReference).GetComponent().cameraRigController; _cameraPostProcess = ((Component)_cameraInstance).GetComponent(); _clipPlaneMesh = new Mesh(); SDKUtils.CreateClipPlane(_clipPlaneMesh, 10, 10, useQuads: true, 1000f); _clipPlaneSimpleMaterial = new Material(SDKShaders.clipPlaneSimpleMaterial); _clipPlaneSimpleDebugMaterial = new Material(SDKShaders.clipPlaneSimpleDebugMaterial); _clipPlaneComplexMaterial = new Material(SDKShaders.clipPlaneComplexMaterial); _clipPlaneComplexDebugMaterial = new Material(SDKShaders.clipPlaneComplexDebugMaterial); _writeOpaqueToAlphaMaterial = new Material(SDKShaders.writeOpaqueToAlphaMaterial); _combineAlphaMaterial = new Material(SDKShaders.combineAlphaMaterial); _writeMaterial = new Material(SDKShaders.writeMaterial); _forceForwardRenderingMaterial = new Material(SDKShaders.forceForwardRenderingMaterial); _uiTransparentMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("UnlitTransparentMat"); _clipPlaneCommandBuffer = new CommandBuffer(); _combineAlphaCommandBuffer = new CommandBuffer(); _captureTextureCommandBuffer = new CommandBuffer(); _applyTextureCommandBuffer = new CommandBuffer(); _optimizedRenderingCommandBuffer = new CommandBuffer(); GameObject val2 = new GameObject("LIV UI Camera"); val2.transform.SetParent(((Component)_cameraInstance).transform); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; _uiCameraInstance = val2.AddComponent(); _uiCameraInstance.cullingMask = 1 << LayerIndex.triggerZone.intVal; _uiCameraInstance.clearFlags = (CameraClearFlags)2; _uiCameraInstance.backgroundColor = new Color(0f, 0f, 0f, 0f); _uiCameraInstance.rect = new Rect(0f, 0f, 1f, 1f); _uiCameraInstance.depth = 1f; _uiCameraInstance.stereoTargetEye = (StereoTargetEyeMask)0; _uiCameraInstance.allowHDR = false; _uiCameraInstance.allowMSAA = false; ((Behaviour)_uiCameraInstance).enabled = false; ((Component)_uiCameraInstance).gameObject.SetActive(true); } private void DestroyAssets() { if ((Object)(object)_cameraInstance != (Object)null) { Object.Destroy((Object)(object)((Component)_cameraInstance).gameObject); _cameraInstance = null; } SDKUtils.DestroyObject(ref _clipPlaneMesh); SDKUtils.DestroyObject(ref _clipPlaneSimpleMaterial); SDKUtils.DestroyObject(ref _clipPlaneSimpleDebugMaterial); SDKUtils.DestroyObject(ref _clipPlaneComplexMaterial); SDKUtils.DestroyObject(ref _clipPlaneComplexDebugMaterial); SDKUtils.DestroyObject(ref _writeOpaqueToAlphaMaterial); SDKUtils.DestroyObject(ref _combineAlphaMaterial); SDKUtils.DestroyObject(ref _writeMaterial); SDKUtils.DestroyObject(ref _forceForwardRenderingMaterial); SDKUtils.DisposeObject(ref _clipPlaneCommandBuffer); SDKUtils.DisposeObject(ref _combineAlphaCommandBuffer); SDKUtils.DisposeObject(ref _captureTextureCommandBuffer); SDKUtils.DisposeObject(ref _applyTextureCommandBuffer); SDKUtils.DisposeObject(ref _optimizedRenderingCommandBuffer); } public void Dispose() { ReleaseBridgePoseControl(); DestroyAssets(); SDKUtils.DestroyTexture(ref _backgroundRenderTexture); SDKUtils.DestroyTexture(ref _uiRenderTexture); SDKUtils.DestroyTexture(ref _foregroundRenderTexture); SDKUtils.DestroyTexture(ref _optimizedRenderTexture); SDKUtils.DestroyTexture(ref _complexClipPlaneRenderTexture); } public bool SetPose(Vector3 position, Quaternion rotation, float verticalFieldOfView = 60f, bool useLocalSpace = false) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (_inputFrame.frameid == 0L) { return false; } SDKPose pose = _inputFrame.pose; float num = 1f; if (_resolution.height > 0) { num = (float)_resolution.width / (float)_resolution.height; } if (!useLocalSpace) { Matrix4x4 matrix = Matrix4x4.identity; Transform val = (((Object)(object)stageTransform == (Object)null) ? stage : stageTransform); if ((Object)(object)val != (Object)null) { matrix = val.worldToLocalMatrix; } position = ((Matrix4x4)(ref matrix)).MultiplyPoint(position); rotation = SDKUtils.RotateQuaternionByMatrix(matrix, rotation); } _requestedPose = new SDKPose { localPosition = position, localRotation = rotation, verticalFieldOfView = verticalFieldOfView, projectionMatrix = Matrix4x4.Perspective(verticalFieldOfView, num, pose.nearClipPlane, pose.farClipPlane) }; _requestedPoseFrameIndex = Time.frameCount; return _inputFrame.priority.pose <= 63; } public void SetGroundPlane(float distance, Vector3 normal, bool useLocalSpace = false) { //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) //IL_005c: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) float distance2 = distance; Vector3 val = normal; if (!useLocalSpace) { Matrix4x4 worldToLocalMatrix = (((Object)(object)stageTransform == (Object)null) ? stage : stageTransform).worldToLocalMatrix; Vector3 val2 = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint(normal * distance); val = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyVector(normal); distance2 = 0f - Vector3.Dot(normal, val2); } SDKBridge.SetGroundPlane(new SDKPlane { distance = distance2, normal = val }); } public void SetGroundPlane(Plane plane, bool useLocalSpace = false) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) SetGroundPlane(((Plane)(ref plane)).distance, ((Plane)(ref plane)).normal, useLocalSpace); } public void SetGroundPlane(Transform transform, bool useLocalSpace = false) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)transform == (Object)null)) { Quaternion val = (useLocalSpace ? transform.localRotation : transform.rotation); Vector3 val2 = (useLocalSpace ? transform.localPosition : transform.position); Vector3 val3 = val * Vector3.up; SetGroundPlane(0f - Vector3.Dot(val3, val2), val3, useLocalSpace); } } private void ReleaseBridgePoseControl() { _inputFrame.ReleaseControl(); SDKBridge.UpdateInputFrame(ref _inputFrame); } private void UpdateBridgeResolution() { SDKBridge.GetResolution(ref _resolution); } private void UpdateBridgeInputFrame() { if (_requestedPoseFrameIndex == Time.frameCount) { _inputFrame.ObtainControl(); _inputFrame.pose = _requestedPose; _requestedPose = SDKPose.empty; } else { _inputFrame.ReleaseControl(); } if ((Object)(object)_cameraInstance != (Object)null) { _inputFrame.pose.nearClipPlane = _cameraInstance.nearClipPlane; _inputFrame.pose.farClipPlane = _cameraInstance.farClipPlane; } SDKBridge.UpdateInputFrame(ref _inputFrame); } private void InvokePreRender() { if (_liv.onPreRender != null) { _liv.onPreRender(this); } } private void IvokePostRender() { if (_liv.onPostRender != null) { _liv.onPostRender(this); } } private void InvokePreRenderBackground() { if (_liv.onPreRenderBackground != null) { _liv.onPreRenderBackground(this); } } private void InvokePostRenderBackground() { if (_liv.onPostRenderBackground != null) { _liv.onPostRenderBackground(this); } } private void InvokePreRenderForeground() { if (_liv.onPreRenderForeground != null) { _liv.onPreRenderForeground(this); } } private void InvokePostRenderForeground() { if (_liv.onPostRenderForeground != null) { _liv.onPostRenderForeground(this); } } private void CreateBackgroundTexture() { if (!SDKUtils.CreateTexture(ref _backgroundRenderTexture, _resolution.width, _resolution.height, 24, (RenderTextureFormat)0)) { Debug.LogError((object)"LIV: Unable to create background texture!"); } } private void CreateUITexture() { if (!SDKUtils.CreateTexture(ref _uiRenderTexture, _resolution.width, _resolution.height, 24, (RenderTextureFormat)0)) { Debug.LogError((object)"LIV: Unable to create UI texture!"); } } private void CreateForegroundTexture() { if (!SDKUtils.CreateTexture(ref _foregroundRenderTexture, _resolution.width, _resolution.height, 24, (RenderTextureFormat)0)) { Debug.LogError((object)"LIV: Unable to create foreground texture!"); } } private void CreateOptimizedTexture() { if (!SDKUtils.CreateTexture(ref _optimizedRenderTexture, _resolution.width, _resolution.height, 24, (RenderTextureFormat)0)) { Debug.LogError((object)"LIV: Unable to create optimized texture!"); } } private void CreateComplexClipPlaneTexture() { if (!SDKUtils.CreateTexture(ref _complexClipPlaneRenderTexture, _inputFrame.clipPlane.width, _inputFrame.clipPlane.height, 0, (RenderTextureFormat)0)) { Debug.LogError((object)"LIV: Unable to create complex clip plane texture!"); } } private void UpdateTextures() { if (SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.BACKGROUND_RENDER)) { if ((Object)(object)_backgroundRenderTexture == (Object)null || ((Texture)_backgroundRenderTexture).width != _resolution.width || ((Texture)_backgroundRenderTexture).height != _resolution.height) { CreateBackgroundTexture(); } } else { SDKUtils.DestroyTexture(ref _backgroundRenderTexture); } if ((Object)(object)_uiRenderTexture == (Object)null || ((Texture)_uiRenderTexture).width != _resolution.width || ((Texture)_uiRenderTexture).height != _resolution.height) { CreateUITexture(); } if (SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.FOREGROUND_RENDER)) { if ((Object)(object)_foregroundRenderTexture == (Object)null || ((Texture)_foregroundRenderTexture).width != _resolution.width || ((Texture)_foregroundRenderTexture).height != _resolution.height) { CreateForegroundTexture(); } } else { SDKUtils.DestroyTexture(ref _foregroundRenderTexture); } if (SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.OPTIMIZED_RENDER)) { if ((Object)(object)_optimizedRenderTexture == (Object)null || ((Texture)_optimizedRenderTexture).width != _resolution.width || ((Texture)_optimizedRenderTexture).height != _resolution.height) { CreateOptimizedTexture(); } } else { SDKUtils.DestroyTexture(ref _optimizedRenderTexture); } if (SDKUtils.FeatureEnabled(inputFrame.features, FEATURES.COMPLEX_CLIP_PLANE)) { if ((Object)(object)_complexClipPlaneRenderTexture == (Object)null || ((Texture)_complexClipPlaneRenderTexture).width != _inputFrame.clipPlane.width || ((Texture)_complexClipPlaneRenderTexture).height != _inputFrame.clipPlane.height) { CreateComplexClipPlaneTexture(); } } else { SDKUtils.DestroyTexture(ref _complexClipPlaneRenderTexture); } } private void SendTextureToBridge(RenderTexture texture, TEXTURE_ID id) { SDKBridge.AddTexture(new SDKTexture { id = id, texturePtr = ((Texture)texture).GetNativeTexturePtr(), SharedHandle = IntPtr.Zero, device = SDKUtils.GetDevice(), dummy = 0, type = TEXTURE_TYPE.COLOR_BUFFER, format = TEXTURE_FORMAT.ARGB32, colorSpace = SDKUtils.GetColorSpace(texture), width = ((Texture)texture).width, height = ((Texture)texture).height }); } } internal static class SDKShaders { public static readonly int LIV_COLOR_MASK = Shader.PropertyToID("_LivColorMask"); public static readonly int LIV_TESSELLATION_PROPERTY = Shader.PropertyToID("_LivTessellation"); public static readonly int LIV_CLIP_PLANE_HEIGHT_MAP_PROPERTY = Shader.PropertyToID("_LivClipPlaneHeightMap"); public const string LIV_MR_FOREGROUND_KEYWORD = "LIV_MR_FOREGROUND"; public const string LIV_MR_BACKGROUND_KEYWORD = "LIV_MR_BACKGROUND"; public const string LIV_MR_KEYWORD = "LIV_MR"; public static Material clipPlaneSimpleMaterial { get; private set; } public static Material clipPlaneSimpleDebugMaterial { get; private set; } public static Material clipPlaneComplexMaterial { get; private set; } public static Material clipPlaneComplexDebugMaterial { get; private set; } public static Material writeOpaqueToAlphaMaterial { get; private set; } public static Material combineAlphaMaterial { get; private set; } public static Material writeMaterial { get; private set; } public static Material forceForwardRenderingMaterial { get; private set; } public static void LoadShaders() { clipPlaneSimpleMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_ClipPlaneSimpleMat"); clipPlaneSimpleDebugMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_ClipPlaneSimpleDebugMat"); clipPlaneComplexMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_ClipPlaneComplexMat"); clipPlaneComplexDebugMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_ClipPlaneComplexDebugMat"); writeOpaqueToAlphaMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_WriteOpaqueToAlphaMat"); combineAlphaMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_CombineAlphaMat"); writeMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_WriteMat"); forceForwardRenderingMaterial = global::VRMod.VRMod.VRAssetBundle.LoadAsset("LIV_ForceForwardRenderingMat"); } public static void StartRendering() { Shader.EnableKeyword("LIV_MR"); } public static void StopRendering() { Shader.DisableKeyword("LIV_MR"); } public static void StartForegroundRendering() { Shader.EnableKeyword("LIV_MR_FOREGROUND"); } public static void StopForegroundRendering() { Shader.DisableKeyword("LIV_MR_FOREGROUND"); } public static void StartBackgroundRendering() { Shader.EnableKeyword("LIV_MR_BACKGROUND"); } public static void StopBackgroundRendering() { Shader.DisableKeyword("LIV_MR_BACKGROUND"); } } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct SDKConstants { public const string SDK_ID = "UT4QDBPGHQZHTDVOSRUHN1PZZCM187WV"; public const string SDK_VERSION = "1.5.4"; public const string ENGINE_NAME = "unity"; } public enum PRIORITY : sbyte { NONE = 0, GAME = 63 } [Flags] public enum FEATURES : ulong { NONE = 0uL, BACKGROUND_RENDER = 1uL, FOREGROUND_RENDER = 2uL, COMPLEX_CLIP_PLANE = 4uL, BACKGROUND_DEPTH_RENDER = 8uL, OVERRIDE_POST_PROCESSING = 0x10uL, FIX_FOREGROUND_ALPHA = 0x20uL, GROUND_CLIP_PLANE = 0x40uL, RELEASE_CONTROL = 0x8000uL, OPTIMIZED_RENDER = 0x10000000uL, INTERLACED_RENDER = 0x20000000uL, DEBUG_CLIP_PLANE = 0x1000000000000uL } public enum TEXTURE_ID : uint { UNDEFINED = 0u, BACKGROUND_COLOR_BUFFER_ID = 10u, FOREGROUND_COLOR_BUFFER_ID = 20u, OPTIMIZED_COLOR_BUFFER_ID = 30u } public enum TEXTURE_TYPE : uint { UNDEFINED, COLOR_BUFFER } public enum TEXTURE_FORMAT : uint { UNDEFINED = 0u, ARGB32 = 10u } public enum TEXTURE_DEVICE : uint { UNDEFINED, RAW, DIRECTX, OPENGL, VULKAN, METAL } public enum TEXTURE_COLOR_SPACE : uint { UNDEFINED, LINEAR, SRGB } public enum RENDERING_PIPELINE : uint { UNDEFINED, FORWARD, DEFERRED, VERTEX_LIT, UNIVERSAL, HIGH_DEFINITION } public struct SDKResolution { public int width; public int height; public static SDKResolution zero => new SDKResolution { width = 0, height = 0 }; public override string ToString() { return $"SDKResolution:\nwidth: {width}\nheight: {height}"; } } public struct SDKVector3 { public float x; public float y; public float z; public static SDKVector3 zero => new SDKVector3 { x = 0f, y = 0f, z = 0f }; public static SDKVector3 one => new SDKVector3 { x = 1f, y = 1f, z = 1f }; public static SDKVector3 forward => new SDKVector3 { x = 0f, y = 0f, z = 1f }; public static SDKVector3 up => new SDKVector3 { x = 0f, y = 1f, z = 0f }; public static SDKVector3 right => new SDKVector3 { x = 1f, y = 0f, z = 0f }; public static implicit operator Vector3(SDKVector3 v) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(v.x, v.y, v.z); } public static implicit operator SDKVector3(Vector3 v) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) return new SDKVector3 { x = v.x, y = v.y, z = v.z }; } public static SDKVector3 operator +(SDKVector3 lhs, SDKVector3 rhs) { SDKVector3 result = default(SDKVector3); result.x = lhs.x + rhs.x; result.y = lhs.y + rhs.y; result.z = lhs.z + rhs.z; return result; } public static SDKVector3 operator -(SDKVector3 lhs, SDKVector3 rhs) { SDKVector3 result = default(SDKVector3); result.x = lhs.x - rhs.x; result.y = lhs.y - rhs.y; result.z = lhs.z - rhs.z; return result; } public static SDKVector3 operator *(SDKVector3 lhs, SDKVector3 rhs) { SDKVector3 result = default(SDKVector3); result.x = lhs.x * rhs.x; result.y = lhs.y * rhs.y; result.z = lhs.z * rhs.z; return result; } public static SDKVector3 operator *(SDKVector3 lhs, float rhs) { SDKVector3 result = default(SDKVector3); result.x = lhs.x * rhs; result.y = lhs.y * rhs; result.z = lhs.z * rhs; return result; } public override string ToString() { return $"SDKVector3:\nx: {x}\ny: {y}\nz: {z}"; } } public struct SDKQuaternion { public float x; public float y; public float z; public float w; public static SDKQuaternion identity => new SDKQuaternion { x = 0f, y = 0f, z = 0f, w = 1f }; public static implicit operator Quaternion(SDKQuaternion v) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Quaternion(v.x, v.y, v.z, v.w); } public static implicit operator SDKQuaternion(Quaternion v) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) return new SDKQuaternion { x = v.x, y = v.y, z = v.z, w = v.w }; } public static SDKQuaternion Euler(float pitch, float yaw, float roll) { float num = roll * 0.5f; float num2 = Mathf.Sin(num); float num3 = Mathf.Cos(num); float num4 = pitch * 0.5f; float num5 = Mathf.Sin(num4); float num6 = Mathf.Cos(num4); float num7 = yaw * 0.5f; float num8 = Mathf.Sin(num7); float num9 = Mathf.Cos(num7); float num10 = num9 * num6 * num3 + num8 * num5 * num2; float num11 = num9 * num5 * num3 + num8 * num6 * num2; float num12 = num8 * num6 * num3 - num9 * num5 * num2; float num13 = num9 * num6 * num2 - num8 * num5 * num3; return new SDKQuaternion { x = num11, y = num12, z = num13, w = num10 }; } public static SDKQuaternion operator *(SDKQuaternion lhs, SDKQuaternion rhs) { float num = lhs.w * rhs.x + lhs.x * rhs.w + lhs.y * rhs.z - lhs.z * rhs.y; float num2 = lhs.w * rhs.y + lhs.y * rhs.w + lhs.z * rhs.x - lhs.x * rhs.z; float num3 = lhs.w * rhs.z + lhs.z * rhs.w + lhs.x * rhs.y - lhs.y * rhs.x; float num4 = lhs.w * rhs.w - lhs.x * rhs.x - lhs.y * rhs.y - lhs.z * rhs.z; return new SDKQuaternion { x = num, y = num2, z = num3, w = num4 }; } public static SDKVector3 operator *(SDKQuaternion lhs, SDKVector3 rhs) { float num = lhs.x * 2f; float num2 = lhs.y * 2f; float num3 = lhs.z * 2f; float num4 = lhs.x * num; float num5 = lhs.y * num2; float num6 = lhs.z * num3; float num7 = lhs.x * num2; float num8 = lhs.x * num3; float num9 = lhs.y * num3; float num10 = lhs.w * num; float num11 = lhs.w * num2; float num12 = lhs.w * num3; SDKVector3 result = default(SDKVector3); result.x = (1f - (num5 + num6)) * rhs.x + (num7 - num12) * rhs.y + (num8 + num11) * rhs.z; result.y = (num7 + num12) * rhs.x + (1f - (num4 + num6)) * rhs.y + (num9 - num10) * rhs.z; result.z = (num8 - num11) * rhs.x + (num9 + num10) * rhs.y + (1f - (num4 + num5)) * rhs.z; return result; } public override string ToString() { return $"SDKQuaternion:\nx: {x}\ny: {y}\nz: {z}\nw: {w}"; } } public struct SDKMatrix4x4 { public float m00; public float m01; public float m02; public float m03; public float m10; public float m11; public float m12; public float m13; public float m20; public float m21; public float m22; public float m23; public float m30; public float m31; public float m32; public float m33; public static SDKMatrix4x4 identity => new SDKMatrix4x4 { m00 = 1f, m01 = 0f, m02 = 0f, m03 = 0f, m10 = 0f, m11 = 1f, m12 = 0f, m13 = 0f, m20 = 0f, m21 = 0f, m22 = 1f, m23 = 0f, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 1f }; public static implicit operator Matrix4x4(SDKMatrix4x4 v) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) return new Matrix4x4 { m00 = v.m00, m01 = v.m01, m02 = v.m02, m03 = v.m03, m10 = v.m10, m11 = v.m11, m12 = v.m12, m13 = v.m13, m20 = v.m20, m21 = v.m21, m22 = v.m22, m23 = v.m23, m30 = v.m30, m31 = v.m31, m32 = v.m32, m33 = v.m33 }; } public static implicit operator SDKMatrix4x4(Matrix4x4 v) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) return new SDKMatrix4x4 { m00 = v.m00, m01 = v.m01, m02 = v.m02, m03 = v.m03, m10 = v.m10, m11 = v.m11, m12 = v.m12, m13 = v.m13, m20 = v.m20, m21 = v.m21, m22 = v.m22, m23 = v.m23, m30 = v.m30, m31 = v.m31, m32 = v.m32, m33 = v.m33 }; } public static SDKMatrix4x4 Perspective(float vFov, float aspect, float zNear, float zFar) { float num = vFov * ((float)Math.PI / 180f); float num2 = 2f * Mathf.Atan(Mathf.Tan(num * 0.5f) * aspect); float num3 = 1f / Mathf.Tan(num2 * 0.5f); float num4 = 1f / Mathf.Tan(num * 0.5f); float num5 = (zFar + zNear) / (zNear - zFar); float num6 = 2f * (zFar * zNear) / (zNear - zFar); return new SDKMatrix4x4 { m00 = num3, m01 = 0f, m02 = 0f, m03 = 0f, m10 = 0f, m11 = num4, m12 = 0f, m13 = 0f, m20 = 0f, m21 = 0f, m22 = num5, m23 = num6, m30 = 0f, m31 = 0f, m32 = -1f, m33 = 0f }; } public static SDKMatrix4x4 operator *(SDKMatrix4x4 lhs, SDKMatrix4x4 rhs) { SDKMatrix4x4 result = identity; result.m00 = lhs.m00 * rhs.m00 + lhs.m01 * rhs.m10 + lhs.m02 * rhs.m20 + lhs.m03 * rhs.m30; result.m01 = lhs.m00 * rhs.m01 + lhs.m01 * rhs.m11 + lhs.m02 * rhs.m21 + lhs.m03 * rhs.m31; result.m02 = lhs.m00 * rhs.m02 + lhs.m01 * rhs.m12 + lhs.m02 * rhs.m22 + lhs.m03 * rhs.m32; result.m03 = lhs.m00 * rhs.m03 + lhs.m01 * rhs.m13 + lhs.m02 * rhs.m23 + lhs.m03 * rhs.m33; result.m10 = lhs.m10 * rhs.m00 + lhs.m11 * rhs.m10 + lhs.m12 * rhs.m20 + lhs.m13 * rhs.m30; result.m11 = lhs.m10 * rhs.m01 + lhs.m11 * rhs.m11 + lhs.m12 * rhs.m21 + lhs.m13 * rhs.m31; result.m12 = lhs.m10 * rhs.m02 + lhs.m11 * rhs.m12 + lhs.m12 * rhs.m22 + lhs.m13 * rhs.m32; result.m13 = lhs.m10 * rhs.m03 + lhs.m11 * rhs.m13 + lhs.m12 * rhs.m23 + lhs.m13 * rhs.m33; result.m20 = lhs.m20 * rhs.m00 + lhs.m21 * rhs.m10 + lhs.m22 * rhs.m20 + lhs.m23 * rhs.m30; result.m21 = lhs.m20 * rhs.m01 + lhs.m21 * rhs.m11 + lhs.m22 * rhs.m21 + lhs.m23 * rhs.m31; result.m22 = lhs.m20 * rhs.m02 + lhs.m21 * rhs.m12 + lhs.m22 * rhs.m22 + lhs.m23 * rhs.m32; result.m23 = lhs.m20 * rhs.m03 + lhs.m21 * rhs.m13 + lhs.m22 * rhs.m23 + lhs.m23 * rhs.m33; result.m30 = lhs.m30 * rhs.m00 + lhs.m31 * rhs.m10 + lhs.m32 * rhs.m20 + lhs.m33 * rhs.m30; result.m31 = lhs.m30 * rhs.m01 + lhs.m31 * rhs.m11 + lhs.m32 * rhs.m21 + lhs.m33 * rhs.m31; result.m32 = lhs.m30 * rhs.m02 + lhs.m31 * rhs.m12 + lhs.m32 * rhs.m22 + lhs.m33 * rhs.m32; result.m33 = lhs.m30 * rhs.m03 + lhs.m31 * rhs.m13 + lhs.m32 * rhs.m23 + lhs.m33 * rhs.m33; return result; } public static SDKVector3 operator *(SDKMatrix4x4 lhs, SDKVector3 rhs) { SDKVector3 result = default(SDKVector3); result.x = lhs.m00 * rhs.x + lhs.m01 * rhs.y + lhs.m02 * rhs.z; result.y = lhs.m10 * rhs.x + lhs.m11 * rhs.y + lhs.m12 * rhs.z; result.z = lhs.m20 * rhs.x + lhs.m21 * rhs.y + lhs.m22 * rhs.z; return result; } public static SDKMatrix4x4 Translate(SDKVector3 value) { return new SDKMatrix4x4 { m00 = 1f, m01 = 0f, m02 = 0f, m03 = value.x, m10 = 0f, m11 = 1f, m12 = 0f, m13 = value.y, m20 = 0f, m21 = 0f, m22 = 1f, m23 = value.z, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 1f }; } public static SDKMatrix4x4 Rotate(SDKQuaternion value) { float x = value.x; float y = value.y; float z = value.z; float w = value.w; return new SDKMatrix4x4 { m00 = 1f - 2f * y * y - 2f * z * z, m01 = 2f * x * y - 2f * z * w, m02 = 2f * x * z + 2f * y * w, m03 = 0f, m10 = 2f * x * y + 2f * z * w, m11 = 1f - 2f * x * x - 2f * z * z, m12 = 2f * y * z - 2f * x * w, m13 = 0f, m20 = 2f * x * z - 2f * y * w, m21 = 2f * y * z + 2f * x * w, m22 = 1f - 2f * x * x - 2f * y * y, m23 = 0f, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 1f }; } public static SDKMatrix4x4 Scale(SDKVector3 value) { return new SDKMatrix4x4 { m00 = value.x, m01 = 0f, m02 = 0f, m03 = 0f, m10 = 0f, m11 = value.y, m12 = 0f, m13 = 0f, m20 = 0f, m21 = 0f, m22 = value.z, m23 = 0f, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 1f }; } public static SDKMatrix4x4 TRS(SDKVector3 translation, SDKQuaternion rotation, SDKVector3 scale) { return Translate(translation) * Rotate(rotation) * Scale(scale); } public override string ToString() { return $"Matrix4x4:\n{m00} {m01} {m02} {m03}\n{m10} {m11} {m12} {m13}\n{m20} {m21} {m22} {m23}\n{m30} {m31} {m32} {m33}"; } } public struct SDKPlane { public float distance; public SDKVector3 normal; public static SDKPlane empty => new SDKPlane { distance = 0f, normal = SDKVector3.up }; public static implicit operator SDKPlane(Plane v) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) return new SDKPlane { distance = ((Plane)(ref v)).distance, normal = ((Plane)(ref v)).normal }; } public override string ToString() { return $"SDKPlane:\n{distance} {normal}"; } } public struct SDKPriority { public sbyte pose; public sbyte clipPlane; public sbyte stage; public sbyte resolution; public sbyte feature; public sbyte nearFarAdjustment; public sbyte groundPlane; public sbyte reserved2; public static SDKPriority empty => new SDKPriority { pose = -63, clipPlane = -63, stage = -63, resolution = -63, feature = -63, nearFarAdjustment = 63, groundPlane = -63, reserved2 = -63 }; public override string ToString() { return $"Priority:\npose: {pose}, clipPlane: {clipPlane}, stage: {stage}, resolution: {resolution}, feature: {feature}, nearFarAdjustment: {nearFarAdjustment}, groundPlane: {groundPlane}"; } } public struct SDKApplicationOutput { public FEATURES supportedFeatures; public string engineName; public string engineVersion; public string applicationName; public string applicationVersion; public string xrDeviceName; public string graphicsAPI; public string sdkID; public string sdkVersion; public static SDKApplicationOutput empty => new SDKApplicationOutput { supportedFeatures = FEATURES.NONE, engineName = string.Empty, engineVersion = string.Empty, applicationName = string.Empty, applicationVersion = string.Empty, xrDeviceName = string.Empty, graphicsAPI = string.Empty, sdkID = "UT4QDBPGHQZHTDVOSRUHN1PZZCM187WV", sdkVersion = string.Empty }; public override string ToString() { return $"SDKApplicationOutput:\nsupportedFeatures: {supportedFeatures}\nengineName: {engineName}\nengineVersion: {engineVersion}\napplicationName: {applicationName}\napplicationVersion: {applicationVersion}\nxrDeviceName: {xrDeviceName}\ngraphicsAPI: {graphicsAPI}\nsdkID: {sdkID}\nsdkVersion: {sdkVersion}"; } } public struct SDKInputFrame { public SDKPose pose; public SDKClipPlane clipPlane; public SDKTransform stageTransform; public FEATURES features; public SDKClipPlane groundClipPlane; public ulong frameid; public ulong referenceframe; public SDKPriority priority; public static SDKInputFrame empty => new SDKInputFrame { pose = SDKPose.empty, clipPlane = SDKClipPlane.empty, stageTransform = SDKTransform.empty, features = FEATURES.NONE, groundClipPlane = SDKClipPlane.empty, frameid = 0uL, referenceframe = 0uL, priority = SDKPriority.empty }; public void ReleaseControl() { priority = SDKPriority.empty; } public void ObtainControl() { priority = SDKPriority.empty; priority.pose = 63; } public override string ToString() { return $"SDKInputFrame:\npose: {pose}\nclipPlane: {clipPlane}\nstageTransform: {stageTransform}\nfeatures: {features}\ngroundClipPlane: {groundClipPlane}\nframeid: {frameid}\nreferenceframe: {referenceframe}\npriority: {priority:X4}"; } } public struct SDKOutputFrame { public RENDERING_PIPELINE renderingPipeline; public SDKTrackedSpace trackedSpace; public static SDKOutputFrame empty => new SDKOutputFrame { renderingPipeline = RENDERING_PIPELINE.UNDEFINED, trackedSpace = SDKTrackedSpace.empty }; public override string ToString() { return $"SDKOutputFrame:\nrenderingPipeline: {renderingPipeline}\ntrackedSpace: {trackedSpace}"; } } public struct SDKTrackedSpace { public SDKVector3 trackedSpaceWorldPosition; public SDKQuaternion trackedSpaceWorldRotation; public SDKVector3 trackedSpaceLocalScale; public SDKMatrix4x4 trackedSpaceLocalToWorldMatrix; public SDKMatrix4x4 trackedSpaceWorldToLocalMatrix; public static SDKTrackedSpace empty => new SDKTrackedSpace { trackedSpaceWorldPosition = SDKVector3.zero, trackedSpaceWorldRotation = SDKQuaternion.identity, trackedSpaceLocalScale = SDKVector3.zero, trackedSpaceLocalToWorldMatrix = SDKMatrix4x4.identity, trackedSpaceWorldToLocalMatrix = SDKMatrix4x4.identity }; public override string ToString() { return $"SDKTrackedSpace:\ntrackedSpaceWorldPosition: {trackedSpaceWorldPosition}\ntrackedSpaceWorldRotation: {trackedSpaceWorldRotation}\ntrackedSpaceLocalScale: {trackedSpaceLocalScale}\ntrackedSpaceLocalToWorldMatrix: {trackedSpaceLocalToWorldMatrix}\ntrackedSpaceWorldToLocalMatrix: {trackedSpaceWorldToLocalMatrix}"; } } public struct SDKTexture { public TEXTURE_ID id; public IntPtr texturePtr; public IntPtr SharedHandle; public TEXTURE_DEVICE device; public int dummy; public TEXTURE_TYPE type; public TEXTURE_FORMAT format; public TEXTURE_COLOR_SPACE colorSpace; public int width; public int height; public static SDKTexture empty => new SDKTexture { id = TEXTURE_ID.UNDEFINED, texturePtr = IntPtr.Zero, SharedHandle = IntPtr.Zero, device = TEXTURE_DEVICE.UNDEFINED, dummy = 0, type = TEXTURE_TYPE.UNDEFINED, format = TEXTURE_FORMAT.UNDEFINED, colorSpace = TEXTURE_COLOR_SPACE.UNDEFINED, width = 0, height = 0 }; public override string ToString() { return $"SDKTexture:\nid: {id}\ntexturePtr: {texturePtr}\nSharedHandle: {SharedHandle}\ndevice: {device}\ndummy: {dummy}\ntype: {type}\nformat: {format}\ncolorSpace: {colorSpace}\nwidth: {width}\nheight: {height}"; } } public struct SDKTransform { public SDKVector3 localPosition; public SDKQuaternion localRotation; public SDKVector3 localScale; public static SDKTransform empty => new SDKTransform { localPosition = SDKVector3.zero, localRotation = SDKQuaternion.identity, localScale = SDKVector3.one }; public override string ToString() { return $"SDKTransform:\nlocalPosition: {localPosition}\nlocalRotation: {localRotation}\nlocalScale: {localScale}"; } } public struct SDKClipPlane { public SDKMatrix4x4 transform; public int width; public int height; public float tesselation; public static SDKClipPlane empty => new SDKClipPlane { transform = SDKMatrix4x4.identity, width = 0, height = 0, tesselation = 0f }; public override string ToString() { return $"SDKClipPlane:\ntransform: {transform}\nwidth: {width}\nheight: {height}\ntesselation: {tesselation}"; } } public struct SDKControllerState { public SDKVector3 hmdposition; public SDKQuaternion hmdrotation; public SDKVector3 calibrationcameraposition; public SDKQuaternion calibrationcamerarotation; public SDKVector3 cameraposition; public SDKQuaternion camerarotation; public SDKVector3 leftposition; public SDKQuaternion leftrotation; public SDKVector3 rightposition; public SDKQuaternion rightrotation; public static SDKControllerState empty => new SDKControllerState { hmdposition = SDKVector3.zero, hmdrotation = SDKQuaternion.identity, calibrationcameraposition = SDKVector3.zero, calibrationcamerarotation = SDKQuaternion.identity, cameraposition = SDKVector3.zero, camerarotation = SDKQuaternion.identity, leftposition = SDKVector3.zero, leftrotation = SDKQuaternion.identity, rightposition = SDKVector3.zero, rightrotation = SDKQuaternion.identity }; public override string ToString() { return $"SDKControllerState:\nhmdposition: {hmdposition}\nhmdrotation: {hmdrotation}\ncalibrationcameraposition: {calibrationcameraposition}\ncalibrationcamerarotation: {calibrationcamerarotation}\ncameraposition: {cameraposition}\ncamerarotation: {camerarotation}\nleftposition: {leftposition}\nleftrotation: {leftrotation}\nrightposition: {rightposition}\nrightrotation: {rightrotation}"; } } public struct SDKPose { public SDKMatrix4x4 projectionMatrix; public SDKVector3 localPosition; public SDKQuaternion localRotation; public float verticalFieldOfView; public float nearClipPlane; public float farClipPlane; public int unused0; public int unused1; public static SDKPose empty => new SDKPose { projectionMatrix = SDKMatrix4x4.Perspective(90f, 1f, 0.01f, 1000f), localPosition = SDKVector3.zero, localRotation = SDKQuaternion.identity, verticalFieldOfView = 90f, nearClipPlane = 0.01f, farClipPlane = 1000f }; public override string ToString() { return $"SDKPose:\nprojectionMatrix: {projectionMatrix}\nlocalPosition: {localPosition}\nlocalRotation: {localRotation}\nverticalFieldOfView: {verticalFieldOfView}\nnearClipPlane: {nearClipPlane}\nfarClipPlane: {farClipPlane}"; } } public static class SDKUtils { public static TEXTURE_COLOR_SPACE GetDefaultColorSpace { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 ColorSpace activeColorSpace = QualitySettings.activeColorSpace; if ((int)activeColorSpace != 0) { if ((int)activeColorSpace == 1) { return TEXTURE_COLOR_SPACE.LINEAR; } return TEXTURE_COLOR_SPACE.UNDEFINED; } return TEXTURE_COLOR_SPACE.SRGB; } } public static void CreateClipPlane(Mesh mesh, int resX, int resY, bool useQuads, float skirtLength) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) int num = (resX + 1) * (resY + 1); int num2 = (useQuads ? (resX * resY * 4) : (resX * resY * 2 * 3)); Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector2[] array2 = (Vector2[])(object)new Vector2[num]; int[] array3 = new int[num2]; float num3 = 0.5f; float num4 = 0.5f; int num5 = resX + 1; int num6 = resY + 1; for (int i = 0; i < num6; i++) { for (int j = 0; j < num5; j++) { int num7 = i * num5 + j; float num8 = (float)j / (float)resX; float num9 = (float)i / (float)resY; float num10 = ((j == 0 || j == resX) ? skirtLength : 1f); float num11 = ((i == 0 || i == resY) ? skirtLength : 1f); array[num7] = Vector2.op_Implicit(new Vector2((0f - num3 + num8) * num10, (0f - num4 + num9) * num11)); array2[num7] = new Vector2(Mathf.InverseLerp(1f, (float)(resX - 1), (float)j), Mathf.InverseLerp(1f, (float)(resY - 1), (float)i)); } } mesh.Clear(); mesh.vertices = array; mesh.uv = array2; mesh.bounds = new Bounds(Vector3.zero, Vector3.one * float.MaxValue); int num12 = resX * resY; int num13 = 0; int num14 = 0; if (useQuads) { for (int k = 0; k < num12; k++) { num13 = k / resX * num5 + k % resX; array3[num14++] = num13 + 1; array3[num14++] = num13; array3[num14++] = num13 + 1 + resX; array3[num14++] = num13 + 2 + resX; } mesh.SetIndices(array3, (MeshTopology)2, 0); return; } for (int l = 0; l < num12; l++) { num13 = l / resX * num5 + l % resX; array3[num14++] = num13 + 2 + resX; array3[num14++] = num13 + 1; array3[num14++] = num13; array3[num14++] = num13 + 1 + resX; array3[num14++] = num13 + 2 + resX; array3[num14++] = num13; } mesh.SetIndices(array3, (MeshTopology)0, 0); } public static RenderTextureReadWrite GetReadWriteFromColorSpace(TEXTURE_COLOR_SPACE colorSpace) { return (RenderTextureReadWrite)(colorSpace switch { TEXTURE_COLOR_SPACE.LINEAR => 1, TEXTURE_COLOR_SPACE.SRGB => 2, _ => 0, }); } public static TEXTURE_COLOR_SPACE GetColorSpace(RenderTexture renderTexture) { if ((Object)(object)renderTexture == (Object)null) { return TEXTURE_COLOR_SPACE.UNDEFINED; } if (renderTexture.sRGB) { return TEXTURE_COLOR_SPACE.SRGB; } return TEXTURE_COLOR_SPACE.LINEAR; } public static RENDERING_PIPELINE GetRenderingPipeline(RenderingPath renderingPath) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown return (int)renderingPath switch { 2 => RENDERING_PIPELINE.DEFERRED, 3 => RENDERING_PIPELINE.DEFERRED, 1 => RENDERING_PIPELINE.FORWARD, 0 => RENDERING_PIPELINE.VERTEX_LIT, _ => RENDERING_PIPELINE.UNDEFINED, }; } public static TEXTURE_DEVICE GetDevice() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown GraphicsDeviceType graphicsDeviceType = SystemInfo.graphicsDeviceType; if ((int)graphicsDeviceType != 2) { switch (graphicsDeviceType - 16) { case 2: break; case 5: return TEXTURE_DEVICE.VULKAN; case 0: return TEXTURE_DEVICE.METAL; case 1: return TEXTURE_DEVICE.OPENGL; default: return TEXTURE_DEVICE.UNDEFINED; } } return TEXTURE_DEVICE.DIRECTX; } public static bool ContainsFlag(ulong flags, ulong flag) { return (flags & flag) != 0; } public static ulong SetFlag(ulong flags, ulong flag, bool enabled) { if (enabled) { return flags | flag; } return flags & ~flag; } public static void GetCameraPositionAndRotation(SDKPose pose, Matrix4x4 originLocalToWorldMatrix, out Vector3 position, out Quaternion rotation) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) position = ((Matrix4x4)(ref originLocalToWorldMatrix)).MultiplyPoint((Vector3)pose.localPosition); rotation = RotateQuaternionByMatrix(originLocalToWorldMatrix, pose.localRotation); } public static void CleanCameraBehaviours(Camera camera, string[] excludeBehaviours) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) foreach (Transform item in ((Component)camera).transform) { Object.Destroy((Object)(object)((Component)item).gameObject); } if (excludeBehaviours != null) { for (int i = 0; i < excludeBehaviours.Length; i++) { Object.Destroy((Object)(object)((Component)camera).GetComponent(excludeBehaviours[i])); } } } public static void SetCamera(Camera camera, Transform cameraTransform, SDKInputFrame inputFrame, Matrix4x4 originLocalToWorldMatrix, int layerMask) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0041: 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_0054: 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) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Vector3 position = Vector3.zero; Quaternion rotation = Quaternion.identity; float verticalFieldOfView = inputFrame.pose.verticalFieldOfView; float nearClipPlane = inputFrame.pose.nearClipPlane; float farClipPlane = inputFrame.pose.farClipPlane; Matrix4x4 projectionMatrix = inputFrame.pose.projectionMatrix; GetCameraPositionAndRotation(inputFrame.pose, originLocalToWorldMatrix, out position, out rotation); cameraTransform.position = position; cameraTransform.rotation = rotation; camera.fieldOfView = verticalFieldOfView; camera.nearClipPlane = nearClipPlane; camera.farClipPlane = farClipPlane; camera.projectionMatrix = projectionMatrix; camera.cullingMask = layerMask; } public static Quaternion RotateQuaternionByMatrix(Matrix4x4 matrix, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) //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) return Quaternion.LookRotation(((Matrix4x4)(ref matrix)).MultiplyVector(Vector3.forward), ((Matrix4x4)(ref matrix)).MultiplyVector(Vector3.up)) * rotation; } public static SDKTrackedSpace GetTrackedSpace(Transform transform) { //IL_001a: 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_003e: 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) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform == (Object)null) { return SDKTrackedSpace.empty; } return new SDKTrackedSpace { trackedSpaceWorldPosition = transform.position, trackedSpaceWorldRotation = transform.rotation, trackedSpaceLocalScale = transform.localScale, trackedSpaceLocalToWorldMatrix = transform.localToWorldMatrix, trackedSpaceWorldToLocalMatrix = transform.worldToLocalMatrix }; } public static bool DestroyObject(ref T reference) where T : Object { if ((Object)(object)reference == (Object)null) { return false; } Object.Destroy((Object)(object)reference); reference = default(T); return true; } public static bool DisposeObject(ref T reference) where T : IDisposable { if (reference == null) { return false; } reference.Dispose(); reference = default(T); return true; } public static bool CreateTexture(ref RenderTexture renderTexture, int width, int height, int depth, RenderTextureFormat format) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown DestroyTexture(ref renderTexture); if (width <= 0 || height <= 0) { Debug.LogError((object)"LIV: Unable to create render texture. Texture dimension must be higher than zero."); return false; } renderTexture = new RenderTexture(width, height, depth, format) { antiAliasing = 1, wrapMode = (TextureWrapMode)1, useMipMap = false, anisoLevel = 0 }; if (!renderTexture.Create()) { Debug.LogError((object)"LIV: Unable to create render texture."); return false; } return true; } public static void DestroyTexture(ref RenderTexture _renderTexture) { if (!((Object)(object)_renderTexture == (Object)null)) { if (_renderTexture.IsCreated()) { _renderTexture.Release(); } _renderTexture = null; } } public static void ApplyUserSpaceTransform(SDKRender render) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)render.stageTransform == (Object)null)) { render.stageTransform.localPosition = render.inputFrame.stageTransform.localPosition; render.stageTransform.localRotation = render.inputFrame.stageTransform.localRotation; render.stageTransform.localScale = render.inputFrame.stageTransform.localScale; } } public static void CreateBridgeOutputFrame(SDKRender render) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) RENDERING_PIPELINE renderingPipeline = RENDERING_PIPELINE.UNDEFINED; if ((Object)(object)render.cameraInstance != (Object)null) { renderingPipeline = GetRenderingPipeline(render.cameraInstance.actualRenderingPath); } SDKBridge.CreateFrame(new SDKOutputFrame { renderingPipeline = renderingPipeline, trackedSpace = GetTrackedSpace(((Object)(object)render.stageTransform == (Object)null) ? render.stage : render.stageTransform) }); } public static bool FeatureEnabled(FEATURES features, FEATURES feature) { return ContainsFlag((ulong)features, (ulong)feature); } public static void DisableStandardAssets(Camera cameraInstance, ref MonoBehaviour[] behaviours, ref bool[] wasBehaviourEnabled) { behaviours = null; wasBehaviourEnabled = null; behaviours = ((Component)cameraInstance).gameObject.GetComponents(); wasBehaviourEnabled = new bool[behaviours.Length]; for (int i = 0; i < behaviours.Length; i++) { MonoBehaviour val = behaviours[i]; if (((Behaviour)val).enabled && ((object)val).GetType().ToString().StartsWith("UnityStandardAssets.")) { ((Behaviour)val).enabled = false; wasBehaviourEnabled[i] = true; } } } public static void RestoreStandardAssets(ref MonoBehaviour[] behaviours, ref bool[] wasBehaviourEnabled) { if (behaviours == null) { return; } for (int i = 0; i < behaviours.Length; i++) { if (wasBehaviourEnabled[i]) { ((Behaviour)behaviours[i]).enabled = true; } } } public static void ForceForwardRendering(Camera cameraInstance, Mesh clipPlaneMesh, Material forceForwardRenderingMaterial) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) //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_0049: Expected O, but got Unknown Matrix4x4 val = ((Component)cameraInstance).transform.localToWorldMatrix * Matrix4x4.TRS(Vector3.forward * (cameraInstance.nearClipPlane + 0.1f), Quaternion.identity, Vector3.one); Graphics.DrawMesh(clipPlaneMesh, val, forceForwardRenderingMaterial, 0, cameraInstance, 0, new MaterialPropertyBlock(), false, false, false); } } } namespace UnityEngine.XR.Interaction.Toolkit { internal static class InputHelpers { public enum Button { None = 0, MenuButton = 1, Trigger = 2, Grip = 3, TriggerButton = 4, GripButton = 5, PrimaryButton = 6, PrimaryTouch = 7, SecondaryButton = 8, SecondaryTouch = 9, Primary2DAxisTouch = 10, Primary2DAxisClick = 11, Secondary2DAxisTouch = 12, Secondary2DAxisClick = 13, PrimaryAxis2DUp = 14, PrimaryAxis2DDown = 15, PrimaryAxis2DLeft = 16, PrimaryAxis2DRight = 17, SecondaryAxis2DUp = 18, SecondaryAxis2DDown = 19, SecondaryAxis2DLeft = 20, SecondaryAxis2DRight = 21, [Obsolete("TriggerPressed has been deprecated. Use TriggerButton instead. (UnityUpgradable) -> TriggerButton")] TriggerPressed = 4, [Obsolete("GripPressed has been deprecated. Use GripButton instead. (UnityUpgradable) -> GripButton")] GripPressed = 5 } public enum Axis2D { None, PrimaryAxis2D, SecondaryAxis2D } private enum ButtonReadType { None, Binary, Axis1D, Axis2DUp, Axis2DDown, Axis2DLeft, Axis2DRight } private struct ButtonInfo { public string name; public ButtonReadType type; public ButtonInfo(string name, ButtonReadType type) { this.name = name; this.type = type; } } private static readonly ButtonInfo[] s_ButtonData = new ButtonInfo[22] { new ButtonInfo("", ButtonReadType.None), new ButtonInfo("MenuButton", ButtonReadType.Binary), new ButtonInfo("Trigger", ButtonReadType.Axis1D), new ButtonInfo("Grip", ButtonReadType.Axis1D), new ButtonInfo("TriggerButton", ButtonReadType.Binary), new ButtonInfo("GripButton", ButtonReadType.Binary), new ButtonInfo("PrimaryButton", ButtonReadType.Binary), new ButtonInfo("PrimaryTouch", ButtonReadType.Binary), new ButtonInfo("SecondaryButton", ButtonReadType.Binary), new ButtonInfo("SecondaryTouch", ButtonReadType.Binary), new ButtonInfo("Primary2DAxisTouch", ButtonReadType.Binary), new ButtonInfo("Primary2DAxisClick", ButtonReadType.Binary), new ButtonInfo("Secondary2DAxisTouch", ButtonReadType.Binary), new ButtonInfo("Secondary2DAxisClick", ButtonReadType.Binary), new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DUp), new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DDown), new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DLeft), new ButtonInfo("Primary2DAxis", ButtonReadType.Axis2DRight), new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DUp), new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DDown), new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DLeft), new ButtonInfo("Secondary2DAxis", ButtonReadType.Axis2DRight) }; private static readonly string[] s_Axis2DNames = new string[3] { "", "Primary2DAxis", "Secondary2DAxis" }; private const float k_DefaultPressThreshold = 0.1f; public static bool IsPressed(this InputDevice device, Button button, out bool isPressed, float pressThreshold = -1f) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) if ((int)button >= s_ButtonData.Length) { throw new ArgumentException("[InputHelpers.IsPressed] The value of