private void HandleDeviceInput(IVRModuleDeviceStateRW deviceState) { //var leftPressed = Input.GetMouseButton(0); //var rightPressed = Input.GetMouseButton(1); //var midPressed = Input.GetMouseButton(2); bool leftPressed; bool rightPressed; bool midPressed; if ((PlatformType)Enum.Parse(typeof(PlatformType), PlayerPrefs.GetString("CurrentPlateform", "PC")) == PlatformType.PC) { leftPressed = Input.GetMouseButton(0); rightPressed = Input.GetMouseButton(1); midPressed = Input.GetMouseButton(2); } else if ((PlatformType)Enum.Parse(typeof(PlatformType), PlayerPrefs.GetString("CurrentPlateform", "PC")) == PlatformType.zSpace) { ZCore _zCore = GameObject.FindObjectOfType <ZCore>(); midPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 1); leftPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 0); rightPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 2); } else { leftPressed = Input.GetMouseButton(0); rightPressed = Input.GetMouseButton(1); midPressed = Input.GetMouseButton(2); } //Debug.LogError(leftPressed+"|" + midPressed + "|" + midPressed); deviceState.SetButtonPress(VRModuleRawButton.Trigger, leftPressed); deviceState.SetButtonTouch(VRModuleRawButton.Trigger, leftPressed); deviceState.SetAxisValue(VRModuleRawAxis.Trigger, leftPressed ? 1f : 0f); deviceState.SetButtonPress(VRModuleRawButton.Grip, midPressed); deviceState.SetButtonTouch(VRModuleRawButton.Grip, midPressed); deviceState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, midPressed ? 1f : 0f); deviceState.SetButtonPress(VRModuleRawButton.Touchpad, rightPressed); deviceState.SetButtonPress(VRModuleRawButton.ApplicationMenu, IsMenuKeyDown()); deviceState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, IsMenuKeyDown()); if (VIUSettings.simulateTrackpadTouch && IsShiftKeyPressed()) { deviceState.SetButtonTouch(VRModuleRawButton.Touchpad, true); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadX, deviceState.GetAxisValue(VRModuleRawAxis.TouchpadX) + (Input.GetAxisRaw("Mouse X") * 0.1f)); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadY, deviceState.GetAxisValue(VRModuleRawAxis.TouchpadY) + (Input.GetAxisRaw("Mouse Y") * 0.1f)); } else { deviceState.SetButtonTouch(VRModuleRawButton.Touchpad, rightPressed); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadX, 0f); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadY, 0f); } }
private void HandleTapRelease(ZCore sender, ZCore.TrackerEventInfo info) { if (!_logTapEvents) { return; } if (info.TargetType == ZCore.TargetType.Primary) { Debug.Log(string.Format("<color=purple>Stylus Tap Released</color>")); } }
void Start() { _core = GameObject.FindObjectOfType <ZCore>(); if (_core == null) { this.enabled = false; return; } //_core.TargetButtonRelease += HandleButtonRelease; carManage = GameObject.Find("Car").GetComponent <CarManage>(); transparentShader = Shader.Find("Transparent/Diffuse"); defShader = Shader.Find("Beffio/Car Paint Opaque"); }
void Start() { sceneManage = GameObject.Find("PutScripts").GetComponent <SceneManage>(); _core = GameObject.FindObjectOfType <ZCore>(); if (_core == null) { this.enabled = false; return; } // 建立zSpace操作笔模型 _stylusBeamObject = new GameObject("StylusBeam"); _stylusBeamRenderer = _stylusBeamObject.AddComponent <LineRenderer>(); _stylusBeamRenderer.material = new Material(Shader.Find("Transparent/Diffuse")); _stylusBeamRenderer.SetColors(Color.white, Color.white); }
private void HandleButtonRelease(ZCore sender, ZCore.TrackerButtonEventInfo info) { if (!_logButtonEvents) { return; } if (info.TargetType == ZCore.TargetType.Primary) { Debug.Log( string.Format( "<color=green>Stylus Button Released:</color> {0}", info.ButtonId)); } }
////////////////////////////////////////////////////////////////// // Event Handlers ////////////////////////////////////////////////////////////////// private void HandleMove(ZCore sender, ZCore.TrackerEventInfo info) { if (!_logMoveEvents) { return; } if (info.TargetType == ZCore.TargetType.Primary) { Debug.Log( string.Format( "<color=blue>Stylus Moved:</color> Position {0}, Rotation {1}", info.WorldPose.Position, info.WorldPose.Rotation.eulerAngles)); } }
// Use this for initialization void Start() { _core = GameObject.FindObjectOfType <ZCore>(); if (_core == null) { Debug.LogError("Unable to find reference to zSpace.Core.Core Monobehaviour."); this.enabled = false; return; } // Register event handlers. _core.TargetMove += HandleMove; _core.TargetButtonPress += HandleButtonPress; _core.TargetButtonRelease += HandleButtonRelease; _core.TargetTapPress += HandleTapPress; _core.TargetTapRelease += HandleTapRelease; }
private static void zSpaceDeviceInput(IVRModuleDeviceStateRW deviceState) { ZCore _zCore = GameObject.FindObjectOfType <ZCore>(); if (_zCore == null) { return; } var midPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 1); var leftPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 0); var rightPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 2); //Debug.LogError("拖拽VRModuleRawButton.Trigger:"+leftPressed + " |复位VRModuleRawButton.Grip:" + rightPressed + " |缩放VRModuleRawButton.Touchpad:" + midPressed); deviceState.SetButtonPress(VRModuleRawButton.Trigger, leftPressed); deviceState.SetButtonPress(VRModuleRawButton.Grip, rightPressed); deviceState.SetButtonPress(VRModuleRawButton.Touchpad, midPressed); }