private void OnSceneChanged(Scene arg0, Scene arg1) { Console.WriteLine("Resetting origin for steamvr"); if (ViewRInterface.GetInstance() != null) { field.SetValue(tracker, ViewRInterface.GetInstance().Origin); } }
private void Update() { if (MotionSensors != currentMotionSensors && c.IsCapableOf(Capability.MotionSensors)) { currentMotionSensors = MotionSensors; ViewRInterface.RequestCapability(info.DeviceId, Capability.MotionSensors, MotionSensors, PrintResponse); } if (InternalTracking != currentInternalTracking && c.IsCapableOf(Capability.InternalTracking)) { currentInternalTracking = InternalTracking; ViewRInterface.RequestCapability(info.DeviceId, Capability.InternalTracking, InternalTracking, PrintResponse); } if (ExternalTracking != currentExternalTracking && c.IsCapableOf(Capability.ExternalTracking)) { currentExternalTracking = ExternalTracking; ViewRInterface.RequestCapability(info.DeviceId, Capability.ExternalTracking, ExternalTracking, PrintResponse); } if (FrontCamera != currentFrontCamera && c.IsCapableOf(Capability.FrontCamera)) { currentFrontCamera = FrontCamera; ViewRInterface.RequestCapability(info.DeviceId, Capability.FrontCamera, FrontCamera, PrintResponse); } if (BackCamera != currentBackCamera && c.IsCapableOf(Capability.BackCamera)) { currentBackCamera = BackCamera; ViewRInterface.RequestCapability(info.DeviceId, Capability.BackCamera, BackCamera, PrintResponse); } if (ExternalCamera != currentExternalCamera && c.IsCapableOf(Capability.ExternalCamera)) { currentExternalCamera = ExternalCamera; ViewRInterface.RequestCapability(info.DeviceId, Capability.ExternalCamera, ExternalCamera, PrintResponse); } if (Vibration != currentVibration && c.IsCapableOf(Capability.Vibration)) { currentVibration = Vibration; ViewRInterface.RequestCapability(info.DeviceId, Capability.Vibration, Vibration, PrintResponse); } if (Microphone != currentMicrophone && c.IsCapableOf(Capability.Microphone)) { currentMicrophone = Microphone; ViewRInterface.RequestCapability(info.DeviceId, Capability.Microphone, Microphone, PrintResponse); } if (Speaker != currentSpeaker && c.IsCapableOf(Capability.Speaker)) { currentSpeaker = Speaker; ViewRInterface.RequestCapability(info.DeviceId, Capability.Speaker, Speaker, PrintResponse); } if (Keyboard != currentKeyboard && c.IsCapableOf(Capability.Keyboard)) { currentKeyboard = Keyboard; ViewRInterface.RequestCapability(info.DeviceId, Capability.Keyboard, Keyboard, PrintResponse); } if (TouchScreen != currentTouchScreen && c.IsCapableOf(Capability.TouchScreen)) { currentTouchScreen = TouchScreen; ViewRInterface.RequestCapability(info.DeviceId, Capability.TouchScreen, TouchScreen, PrintResponse); } }
void OnConnect(DeviceInfo info, GameObject client) { if (!enabled) { return; } if (info.Capabilities.IsCapableOf(Capability.ExternalTracking)) { Logger.Log("AttachSteamVRTracker.OnConnect: attaching steam vr tracker to device object"); if (client == null) { Logger.Log("AttachSteamVRTracker.OnConnect: client was null"); } Component tracker = client.AddComponent(SteamVRTracker); if (tracker == null) { Logger.Log("AttachSteamVRTracker.OnConnect: tracker was null"); } FieldInfo field = SteamVRTracker.GetField("origin"); if (field == null) { Logger.Log("AttachSteamVRTracker.OnConnect: field was null"); } if (ViewRInterface.GetInstance() == null) { return; } field.SetValue(tracker, ViewRInterface.GetInstance().Origin); CycleSteamVRTrackers cycler = client.AddComponent <CycleSteamVRTrackers>(); cycler.setIndex = SteamVRTracker.GetMethod("SetDeviceIndex"); Logger.Log("SteamVR entry points found."); cycler.tracker = tracker; Logger.Log("AttachSteamVRTracker.OnConnect: finished attaching steam vr tracker to camera"); UpdateSteamVROrigin posUpdater = client.AddComponent <UpdateSteamVROrigin>(); posUpdater.field = field; posUpdater.tracker = tracker; Logger.Log("AttachSteamVRTracker.OnConnect: finished setting field and tracker for updater"); } }