void OnEnable() { displayManager = target as RUISDisplayManager; displays = serializedObject.FindProperty("displays"); ruisMenuPrefab = serializedObject.FindProperty("ruisMenuPrefab"); guiX = serializedObject.FindProperty("guiX"); guiY = serializedObject.FindProperty("guiY"); guiZ = serializedObject.FindProperty("guiZ"); guiScaleX = serializedObject.FindProperty("guiScaleX"); guiScaleY = serializedObject.FindProperty("guiScaleY"); hideMouseOnPlay = serializedObject.FindProperty("hideMouseOnPlay"); displayManagerLink = new SerializedObject(displayManager); guiDisplayChoiceLink = displayManagerLink.FindProperty("guiDisplayChoice"); // allowResolutionDialog = serializedObject.FindProperty("allowResolutionDialog"); displayPrefab = Resources.Load("RUIS/Prefabs/Main RUIS/RUISDisplay") as GameObject; displayBoxStyle = new GUIStyle(); displayBoxStyle.normal.textColor = Color.white; displayBoxStyle.alignment = TextAnchor.MiddleCenter; displayBoxStyle.border = new RectOffset(2, 2, 2, 2); displayBoxStyle.margin = new RectOffset(1, 0, 0, 0); displayBoxStyle.wordWrap = true; monoDisplayTexture = Resources.Load("RUIS/Editor/Textures/monodisplay") as Texture2D; stereoDisplayTexture = Resources.Load("RUIS/Editor/Textures/stereodisplay") as Texture2D; menuCursorPrefab = serializedObject.FindProperty("menuCursorPrefab"); menuLayer = serializedObject.FindProperty("menuLayer"); }
void Start() { RUISInputManager inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; if (useRazerHydra && inputManager && !inputManager.enableRazerHydra) { useRazerHydra = false; // Debug.LogWarning( "Your settings indicate that you want to use Razer Hydra for " // + "character locomotion controls, but you have disabled Razer " // + "Hydra from " + typeof(RUISInputManager)); } if (usePSNavigationController && inputManager && !inputManager.enablePSMove) { usePSNavigationController = false; // Debug.LogWarning( "Your settings indicate that you want to use PS Navigation " // + "controller for character locomotion controls, but you have " // + "disabled PS Move from RUIS InputManager."); } if (useOpenVrController && !RUISDisplayManager.IsOpenVrAccessible()) { useOpenVrController = false; } }
// Use this for initialization void Start() { try { Input.GetButtonDown("RUISMenu"); } catch (UnityException) { ruisMenuButtonDefined = false; } inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; enablePSMove = inputManager.enablePSMove; psMoveIP = inputManager.PSMoveIP; psMovePort = inputManager.PSMovePort; jumpGesture = FindObjectOfType(typeof(RUISJumpGestureRecognizer)) as RUISJumpGestureRecognizer; displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; riftDisplay = displayManager.GetOculusRiftDisplay(); // TODO: This menu should work with any stereo view, not just Rift. riftDisplay.linkedCamera is null when Rift is disabled. if (oculusRiftMenu && riftDisplay && riftDisplay.linkedCamera) { windowRect = new Rect(riftDisplay.linkedCamera.leftCamera.pixelRect.x + riftDisplay.resolutionX / 4 - 100, riftDisplay.resolutionY / 2 - 220, 250, 250); } SaveInputChanges(); }
void Start() { menuScript = this.GetComponent <RUISMenuNGUI>(); if (menuScript == null) { Debug.LogError("Did not find " + typeof(RUISMenuNGUI) + " script!"); } this.guiPlane = this.transform.Find("NGUIControls/planeCollider").GetComponent <Collider>(); if (this.guiPlane == null) { Debug.LogError("Did not find RUIS Menu collider object, onto which mouse selection ray is projected!"); } if (menuScript.transform.parent == null) { Debug.LogError("The parent of GameObject '" + menuScript.name + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you " + "are misusing the " + typeof(RUIS3dGuiCursor) + " script."); } // else if(menuScript.transform.parent.parent == null) // Debug.LogError( "The grand-parent of GameObject '" + menuScript.name // + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you " // + "are misusing the " + typeof(RUIS3dGuiCursor) + " script."); // else // ruisCamera = menuScript.transform.parent.parent.GetComponent<RUISCamera>(); // // if(ruisCamera == null) // Debug.LogError( typeof(RUIS3dGuiCursor) + " script did not find " + typeof(RUISCamera) + " from the parent of " // + menuScript.transform.name + "gameobject! RUIS Menu is unavailable."); ruisDisplayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; if (ruisDisplayManager == null) { this.enabled = false; Debug.LogError("Could not find " + typeof(RUISDisplayManager) + " script, RUIS Menu will not work!"); return; } if (ruisDisplayManager.displays[ruisDisplayManager.guiDisplayChoice] && ruisDisplayManager.displays[ruisDisplayManager.guiDisplayChoice].linkedCamera) { ruisCamera = ruisDisplayManager.displays[ruisDisplayManager.guiDisplayChoice].linkedCamera; } else { Debug.LogError("Could not find the " + typeof(RUISCamera) + " that is linked to the " + typeof(RUISDisplay) + " with RUIS Menu!"); } if (ruisDisplayManager.hideMouseOnPlay && menuScript.currentMenuState != RUISMenuNGUI.RUISMenuStates.calibration) { Cursor.visible = false; } markerObject = ruisDisplayManager.menuCursorPrefab; if (markerObject) { originalLocalScale = this.markerObject.transform.localScale; } }
private void updateCalibratableDevices() { List <string> dropDownChoices = new List <string>(); string currentSelection = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection; //dropDownChoices.Add ("Select device(s)"); if (inputManager.enableKinect) { dropDownChoices.Add("Kinect 1 floor data"); } if (inputManager.enableKinect2) { dropDownChoices.Add("Kinect 2 floor data"); } // NOTE: The dropDownChoices determine the device pair to be calibrated, and they must follow the format "Device A - Device B". // The string must correspond the options in the Awake() method of RUISCoordinateCalibration script if (inputManager.enableKinect && inputManager.enableKinect2) { dropDownChoices.Add("Kinect 1 - Kinect2"); } if (inputManager.enableKinect && inputManager.enablePSMove) { dropDownChoices.Add("Kinect 1 - PSMove"); } if (inputManager.enableKinect2 && inputManager.enablePSMove) { dropDownChoices.Add("Kinect 2 - PSMove"); } if (RUISDisplayManager.IsOpenVrAccessible() && inputManager.enableKinect2) { dropDownChoices.Add("Kinect 2 - OpenVR (controller)"); } if (RUISDisplayManager.IsHmdPresent() && inputManager.enableKinect2) { dropDownChoices.Add("Kinect 2 - OpenVR (HMD)"); } if (RUISDisplayManager.IsHmdPresent() && inputManager.enablePSMove) { dropDownChoices.Add("PSMove - OpenVR (HMD)"); } if (RUISDisplayManager.IsHmdPresent() && inputManager.enableKinect) { dropDownChoices.Add("Kinect 1 - OpenVR (HMD)"); } if (dropDownChoices.Count == 0) { dropDownChoices.Add("Select device(s)"); } this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().items = dropDownChoices; if (!dropDownChoices.Contains(currentSelection)) { this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection = dropDownChoices[0]; } }
public void Start() { displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; distanceFromCameraLerped = distanceFromCamera; if (disableIfOtherDevices) { RUISInputManager inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; if (inputManager) { bool otherDevices = false; string deviceNames = ""; if (inputManager.enableKinect) { deviceNames += "Kinect 1"; otherDevices = true; } if (inputManager.enableKinect2) { deviceNames += "Kinect 2"; otherDevices = true; } if (inputManager.enableRazerHydra) { if (deviceNames.Length > 0) { deviceNames += ", "; } deviceNames += "Razer Hydra"; otherDevices = true; } if (inputManager.enablePSMove) { if (deviceNames.Length > 0) { deviceNames += ", "; } deviceNames += "PS Move"; otherDevices = true; } if (otherDevices) { Debug.Log("Disabling MouseWand GameObject '" + gameObject.name + "' because the " + "following input devices were found: " + deviceNames); gameObject.SetActive(false); } } } if (!displayManager) { Debug.LogError("RUISMouseWand requires a RUISDisplayManager in the scene!"); } }
public static string GetHmdModel() { if (!RUISDisplayManager.IsHmdPresent()) { return("no_HMD"); } string hmdModel = UnityEngine.VR.VRDevice.model; // Lets ask OpenVR if Unity does not recognice the HMD name if (hmdModel == null || hmdModel == "") { /* #if UNITY_EDITOR * //if(SteamVR.instance != null) * // return SteamVR.instance.hmd_ModelNumber; #else * if(isSteamVrAccessible) * { * if(SteamVR.instance != null) * return SteamVR.instance.hmd_ModelNumber; * } * else * { * if(!failedToAccessSteamVr) * { * try * { * if(SteamVR.instance != null) * hmdModel = SteamVR.instance.hmd_ModelNumber; * isSteamVrAccessible = true; * } * catch * { * failedToAccessSteamVr = true; * } * } * } #endif */ } else { return(hmdModel); } if (hmdModel == null || hmdModel == "") { return("unknown HMD"); } return(hmdModel); }
public void Start() { displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; distanceFromCameraLerped = distanceFromCamera; if(disableIfOtherDevices) { RUISInputManager inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; if(inputManager) { bool otherDevices = false; string deviceNames = ""; if(inputManager.enableKinect) { deviceNames += "Kinect 1"; otherDevices = true; } if(inputManager.enableKinect2) { deviceNames += "Kinect 2"; otherDevices = true; } if(inputManager.enableRazerHydra) { if(deviceNames.Length > 0) deviceNames += ", "; deviceNames += "Razer Hydra"; otherDevices = true; } if(inputManager.enablePSMove) { if(deviceNames.Length > 0) deviceNames += ", "; deviceNames += "PS Move"; otherDevices = true; } if(otherDevices) { Debug.Log( "Disabling MouseWand GameObject '" + gameObject.name + "' because the " + "following input devices were found: " + deviceNames ); gameObject.SetActive(false); } } } if (!displayManager) { Debug.LogError("RUISMouseWand requires a RUISDisplayManager in the scene!"); } }
// RUIS CORE HACK void Start() { if (this.transform.parent) { ruisCamera = this.transform.parent.GetComponent <RUISCamera>(); if (!ruisCamera) { ruisCamera = this.transform.GetComponent <RUISCamera>(); // Non stereo camera } } displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; }
void Start() { menuScript = this.GetComponent <RUISMenuNGUI>(); if (menuScript == null) { Debug.LogError("Did not find " + typeof(RUISMenuNGUI) + " script!"); } this.guiPlane = this.transform.Find("NGUIControls/planeCollider").GetComponent <Collider>(); if (this.guiPlane == null) { Debug.LogError("Did not find RUIS Menu collider object, onto which mouse selection ray is projected!"); } if (menuScript.transform.parent == null) { Debug.LogError("The parent of GameObject '" + menuScript.name + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you " + "are misusing the " + typeof(RUIS3dGuiCursor) + " script."); } else if (menuScript.transform.parent.parent == null) { Debug.LogError("The grand-parent of GameObject '" + menuScript.name + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you " + "are misusing the " + typeof(RUIS3dGuiCursor) + " script."); } else { ruisCamera = menuScript.transform.parent.parent.GetComponent <RUISCamera>(); } if (ruisCamera == null) { Debug.LogError(typeof(RUIS3dGuiCursor) + " script did not find " + typeof(RUISCamera) + " from the parent of " + menuScript.transform.name + "gameobject! RUIS Menu is unavailable."); } ruisDisplayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; if (ruisDisplayManager == null) { this.enabled = false; Debug.LogError("Could not find " + typeof(RUISDisplayManager) + " script, RUIS menu will not work!"); return; } if (ruisDisplayManager.hideMouseOnPlay && menuScript.currentMenuState != RUISMenuNGUI.RUISMenuStates.calibration) { Screen.showCursor = false; } markerObject = ruisDisplayManager.menuCursorPrefab; }
public void Awake() { aspectRatio = resolutionX / resolutionY; if (linkedCamera) { LinkToCamera(linkedCamera); } if (isHmdDisplay && !RUISDisplayManager.IsHmdPresent()) { isHmdDisplay = false; } }
public void Awake() { rotationFilter = new KalmanFilteredRotation(); rotationFilter.skipIdenticalMeasurements = true; rotationFilter.rotationNoiseCovariance = rotationNoiseCovariance; bodyTrackingDeviceID = (int)bodyTrackingDevice; RUISGestureRecognizer[] gestureRecognizerScripts = GetComponents <RUISGestureRecognizer>(); foreach (RUISGestureRecognizer script in gestureRecognizerScripts) { if (script.ToString() != gestureSelectionScriptName) { script.enabled = false; } else { gestureRecognizer = script; } } if (!skeletonManager) { skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager; } selectionVisualizers = new Texture2D[8]; for (int i = 0; i < amountOfSelectionVisualizerImages; i++) { selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D; } displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; if (!gestureRecognizer) { Debug.LogWarning(typeof(RUISGestureRecognizer) + " component was not found for wand '" + name + "'." + "Add it if you want to use gesture-based selection."); } wandSelector = GetComponent <RUISWandSelector>(); if (!wandSelector) { Debug.LogError(typeof(RUISWandSelector) + " component was not found for wand '" + name + "'." + "Add it if you want to use gesture-based selection. Disabling wand."); this.enabled = false; } PlayerLost(); }
// *** HACK TODO need to check if the found HMD is really position tracked public static bool IsHmdPositionTrackable() { // if(OVRManager.capiHmd != null) // { // Ovr.HmdType ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; //06to08 // // if( (OVRManager.capiHmd.GetTrackingState().StatusFlags & (uint)StatusBits.HmdConnected) != 0 // !isplay.isPresent // && (ovrHmdVersion == HmdType.DK2 || ovrHmdVersion == HmdType.Other)) // Rift is DK2+ //06to08 // return true; // } // return false; return(RUISDisplayManager.IsHmdPresent()); }
public void Awake() { rotationFilter = new KalmanFilteredRotation(); rotationFilter.skipIdenticalMeasurements = true; rotationFilter.rotationNoiseCovariance = rotationNoiseCovariance; bodyTrackingDeviceID = (int)bodyTrackingDevice; RUISGestureRecognizer[] gestureRecognizerScripts = GetComponents<RUISGestureRecognizer>(); foreach(RUISGestureRecognizer script in gestureRecognizerScripts) { if(script.ToString() != gestureSelectionScriptName) script.enabled = false; else gestureRecognizer = script; } if (!skeletonManager) { skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager; } selectionVisualizers = new Texture2D[8]; for (int i = 0; i < amountOfSelectionVisualizerImages; i++) { selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D; } displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; if (!gestureRecognizer) { Debug.LogWarning( typeof(RUISGestureRecognizer) + " component was not found for wand '" + name + "'." + "Add it if you want to use gesture-based selection."); } wandSelector = GetComponent<RUISWandSelector>(); if(!wandSelector) { Debug.LogError( typeof(RUISWandSelector) + " component was not found for wand '" + name + "'." + "Add it if you want to use gesture-based selection. Disabling wand."); this.enabled = false; } PlayerLost(); }
public bool HasNonHmdDisplay() { if (!UnityEngine.VR.VRSettings.enabled || !RUISDisplayManager.IsHmdPresent()) { return(true); } foreach (RUISDisplay display in displays) { if (display.linkedCamera) { if (display.linkedCamera.isStereo || (display.linkedCamera.centerCamera && display.linkedCamera.centerCamera.stereoTargetEye == StereoTargetEyeMask.None)) { return(true); } } } return(false); }
void OnEnable() { xmlFilename = serializedObject.FindProperty("xmlFilename"); displaySchema = serializedObject.FindProperty("displaySchema"); loadFromFileInEditor = serializedObject.FindProperty("loadFromFileInEditor"); resolutionX = serializedObject.FindProperty("resolutionX"); resolutionY = serializedObject.FindProperty("resolutionY"); displayWidth = serializedObject.FindProperty("width"); displayHeight = serializedObject.FindProperty("height"); isStereo = serializedObject.FindProperty("isStereo"); enableOculusRift = serializedObject.FindProperty("enableOculusRift"); oculusLowPersistence = serializedObject.FindProperty("oculusLowPersistence"); oculusMirrorMode = serializedObject.FindProperty("oculusMirrorMode"); isObliqueFrustum = serializedObject.FindProperty("isObliqueFrustum"); isKeystoneCorrected = serializedObject.FindProperty("isKeystoneCorrected"); camera = serializedObject.FindProperty("_linkedCamera"); eyeSeparation = serializedObject.FindProperty("eyeSeparation"); stereoType = serializedObject.FindProperty("stereoType"); useDoubleTheSpace = serializedObject.FindProperty("useDoubleTheSpace"); headTracker = serializedObject.FindProperty("headTracker"); displayCenterPosition = serializedObject.FindProperty("displayCenterPosition"); displayNormal = serializedObject.FindProperty("displayNormalInternal"); displayUp = serializedObject.FindProperty("displayUpInternal"); displayBoxStyle = new GUIStyle(); displayBoxStyle.normal.textColor = Color.white; displayBoxStyle.alignment = TextAnchor.MiddleCenter; displayBoxStyle.border = new RectOffset(2, 2, 2, 2); displayBoxStyle.margin = new RectOffset(10, 10, 2, 2); monoDisplayTexture = Resources.Load("RUIS/Editor/Textures/monodisplay") as Texture2D; stereoDisplayTexture = Resources.Load("RUIS/Editor/Textures/stereodisplay") as Texture2D; displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; previousOculusLowPersistenceValue = oculusLowPersistence.boolValue; }
void Start() { menuScript = this.GetComponent<RUISMenuNGUI>(); if(menuScript == null) Debug.LogError( "Did not find " + typeof(RUISMenuNGUI) + " script!"); this.guiPlane = this.transform.Find ("NGUIControls/planeCollider").GetComponent<Collider>(); if(this.guiPlane == null) Debug.LogError( "Did not find RUIS Menu collider object, onto which mouse selection ray is projected!" ); if(menuScript.transform.parent == null) Debug.LogError( "The parent of GameObject '" + menuScript.name + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you " + "are misusing the " + typeof(RUIS3dGuiCursor) + " script."); else if(menuScript.transform.parent.parent == null) Debug.LogError( "The grand-parent of GameObject '" + menuScript.name + " is null and RUIS Menu will not function. Something is wrong with 'RUIS NGUI Menu' prefab or you " + "are misusing the " + typeof(RUIS3dGuiCursor) + " script."); else ruisCamera = menuScript.transform.parent.parent.GetComponent<RUISCamera>(); if(ruisCamera == null) Debug.LogError( typeof(RUIS3dGuiCursor) + " script did not find " + typeof(RUISCamera) + " from the parent of " + menuScript.transform.name + "gameobject! RUIS Menu is unavailable."); ruisDisplayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; if(ruisDisplayManager == null) { this.enabled = false; Debug.LogError("Could not find " + typeof(RUISDisplayManager) + " script, RUIS menu will not work!"); return; } if(ruisDisplayManager.hideMouseOnPlay && menuScript.currentMenuState != RUISMenuNGUI.RUISMenuStates.calibration) Cursor.visible = false; markerObject = ruisDisplayManager.menuCursorPrefab; if(markerObject) originalLocalScale = this.markerObject.transform.localScale; }
void Update() { // if(RUISOVRManager.ovrHmd != null) //06to08 if (RUISDisplayManager.IsHmdPresent()) { Vector3 tempSample = Vector3.zero; // Ovr.Posef headpose = RUISOVRManager.ovrHmd.GetTrackingState().HeadPose.ThePose; // float px = headpose.Position.x; // float py = headpose.Position.y; // float pz = -headpose.Position.z; // This needs to be negated TODO: might change with future OVR version // // tempSample = new Vector3(px, py, pz); // // tempSample = coordinateSystem.ConvertRawOculusDK2Location(tempSample); // HACK TODO if this doesn't work for major HMDs, add wrapper (also for rotation) // HACK TODO tempSample components might need negation or other hackery tempSample = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.Head); //06to08 Vector3 convertedLocation = coordinateSystem.ConvertLocation(tempSample, RUISDevice.OpenVR); this.transform.localPosition = convertedLocation; this.transform.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.Head); // HACK TODO check that this works // if(OVRManager.capiHmd != null) // { // try // { // this.transform.localRotation = OVRManager.capiHmd.GetTrackingState().HeadPose.ThePose.Orientation.ToQuaternion(); // } // catch(System.Exception e) // { // Debug.LogError(e.Message); // } // } } }
// Ovr.HmdType ovrHmdVersion; //06to08 void Awake() { // BUTTONS // Phase: select and configure devices buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Calibration").gameObject); buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Display Management").gameObject); buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Save Config & Restart Scene").gameObject); buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Discard Configuration").gameObject); buttons.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Quit Application").gameObject); // Phase: key stone configuration buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - Reset Keystoning").gameObject); buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - Save Configurations").gameObject); buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - Load Old Configurations").gameObject); buttons.Add(this.transform.Find("NGUIControls/Panel/keyStoneConfiguration/Button - End Display Editing").gameObject); // CHECKBOXES checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect/Checkbox - Use Kinect").gameObject); checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect2/Checkbox - Use Kinect 2").gameObject); checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect/Checkbox - Use Kinect Drift Correction").gameObject); checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Checkbox - Use PSMove").gameObject); checkBoxes.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Hydra/Checkbox - Use Hydra").gameObject); // TEXTFIELDS textFields.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Input - PSMove Port").gameObject); textFields.Add(this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Input - PSMove IP").gameObject); inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem; kinectOrigGUIPos = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect").transform.localPosition; kinect2OrigGUIPos = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Kinect2").transform.localPosition; hydraOrigGUIPos = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Hydra").transform.localPosition; infotextOrigGUIPos = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts").transform.localPosition; // psMoveOrigGUIPos = this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/PSMove").transform.localPosition; // buttonsOrigGUIPos = this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons").transform.localPosition; }
public void Awake() { if (!skeletonManager) { skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager; } selectionVisualizers = new Texture2D[8]; for (int i = 0; i < amountOfSelectionVisualizerImages; i++) { selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D; } displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; if (!gestureRecognizer) { Debug.LogWarning("Please set a gesture recognizer for wand: " + name + " if you want to use gestures."); } wandSelector = GetComponent<RUISWandSelector>(); PlayerLost(); }
public void Awake() { if (!skeletonManager) { skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager; } selectionVisualizers = new Texture2D[8]; for (int i = 0; i < amountOfSelectionVisualizerImages; i++) { selectionVisualizers[i] = Resources.Load("RUIS/Graphics/Selection/visualizer" + (i + 1)) as Texture2D; } displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; if (!gestureRecognizer) { Debug.LogWarning("Please set a gesture recognizer for wand: " + name + " if you want to use gestures."); } wandSelector = GetComponent <RUISWandSelector>(); PlayerLost(); }
void LateUpdate() { // If we are in calibration scene, disable 3d cursor if (this.transform.parent == null) { this.enabled = false; return; } // TODO: instead of searching hierarchy on every frame, find the UICameras more efficiently uiCamera = ruisCamera.transform.GetComponentInChildren <UICamera>(); //menuScript.transform.parent.parent.GetComponentsInChildren<UICamera>(); if (menuScript.menuIsVisible && !instancedCursor) { instancedCursor = Instantiate(this.markerObject) as GameObject; } if (!menuScript.menuIsVisible && instancedCursor) { Destroy(instancedCursor); } if (!menuScript.menuIsVisible) { return; } mouseInputCoordinates = Input.mousePosition; if (ruisCamera.centerCamera) { if (instancedCursor) { instancedCursor.transform.rotation = ruisCamera.centerCamera.transform.rotation; } } else { if (instancedCursor) { instancedCursor.transform.rotation = ruisCamera.transform.rotation; } } // HACK for MecanimBlendedCharacter: Keep cursor visible size even if character is scaled if (menuScript.transform.parent) { instancedCursor.transform.localScale = originalLocalScale * Mathf.Max(menuScript.transform.parent.lossyScale.x, menuScript.transform.parent.lossyScale.y); } RaycastHit hit; if (uiCamera) { /* * if(!ruisCamera.associatedDisplay.isStereo * && (camera.gameObject.name == "CameraLeft" || camera.gameObject.name == "CameraRight" || camera.gameObject.name == "guiCameraForRift" ||)) ||{ || camera.enabled = false; || continue; ||} || ||if(ruisCamera.associatedDisplay.isStereo || && !ruisCamera.associatedDisplay.enableOculusRift || && !(camera.gameObject.name == "CameraLeft" || camera.gameObject.name == "CameraRight" || )) || { || camera.enabled = false; || continue; || } ||if(ruisCamera.associatedDisplay.enableOculusRift || && camera.gameObject.name != "guiCameraForRift") || { || camera.enabled = false; || continue; || } */ Ray ray; Camera rayCamera = uiCamera.GetComponent <Camera>(); if (rayCamera) { if (UnityEngine.XR.XRSettings.enabled && rayCamera.stereoTargetEye != StereoTargetEyeMask.None) // if(ruisCamera.associatedDisplay != null && ruisCamera.associatedDisplay.isHmdDisplay) { // *** TODO remove this hack when Camera.ScreenPointToRay() works again ray = RUISDisplayManager.HMDScreenPointToRay(mouseInputCoordinates, rayCamera); } else { ray = rayCamera.ScreenPointToRay(mouseInputCoordinates); } } else { ray = new Ray(); } if (ruisCamera.associatedDisplay != null && ruisCamera.associatedDisplay.isObliqueFrustum) { Quaternion outerRot = ruisCamera.transform.rotation; wallOrientation = Quaternion.LookRotation(-ruisCamera.associatedDisplay.DisplayNormal, ruisCamera.associatedDisplay.DisplayUp); // *** HACK why is this sign flip necessary to keep the menu at right place?? outerRot = new Quaternion(outerRot.x, outerRot.y, -outerRot.z, outerRot.w); instancedCursor.transform.rotation = outerRot * wallOrientation; trackerPosition = outerRot * ruisCamera.KeystoningHeadTrackerPosition; ray.origin += trackerPosition - outerRot * (new Vector3(ruisDisplayManager.guiX, ruisDisplayManager.guiY, ruisDisplayManager.guiZ)); // ray.direction = wallOrientation * ray.direction; } if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask(LayerMask.LayerToName(ruisDisplayManager.menuLayer)))) { if (instancedCursor) { instancedCursor.transform.position = hit.point; if (!wasVisible) { instancedCursor.SetActive(true); } wasVisible = true; } #if UNITY_EDITOR Debug.DrawLine(ray.origin, hit.point); #endif } else { if (wasVisible) { instancedCursor.SetActive(false); } wasVisible = false; } } }
void Awake() { string[] names = System.Enum.GetNames(typeof(RUISDevice)); foreach (string device in names) { RUISDevice device1Enum = (RUISDevice)System.Enum.Parse(typeof(RUISDevice), device, true); RUISCalibrationResultsFloorPitchRotation[device1Enum] = Quaternion.identity; RUISCalibrationResultsDistanceFromFloor[device1Enum] = 0.0f; foreach (string device2 in names) { if (device != device2) { string devicePairString = device + "-" + device2; RUISCalibrationResultsInVector3[devicePairString] = new Vector3(0, 0, 0); RUISCalibrationResultsInQuaternion[devicePairString] = Quaternion.identity; RUISCalibrationResultsIn4x4Matrix[devicePairString] = Matrix4x4.identity; } } } if (loadFromXML) { if (!LoadMultiXML(coordinateXmlFile)) { createExampleXML(coordinateXmlFile); } } inputManager = FindObjectOfType <RUISInputManager>(); if (switchToAvailableDevice && inputManager) { bool needToSwitch = false; RUISDevice previousDevice = rootDevice; switch (rootDevice) { case RUISDevice.Kinect_1: if (!inputManager.enableKinect) { needToSwitch = true; } break; case RUISDevice.Kinect_2: if (!inputManager.enableKinect2) { needToSwitch = true; } break; case RUISDevice.PS_Move: if (!inputManager.enablePSMove) { needToSwitch = true; } break; case RUISDevice.OpenVR: // If OpenVR can't accessed AND a HMD can't be detected if (!RUISDisplayManager.IsOpenVrAccessible() && !RUISDisplayManager.IsHmdPresent()) { needToSwitch = true; } break; } if (needToSwitch) { // Try to determine if Kinect2 can be used (because this method is run before RUISInputManager can disable enableKinect2) bool kinect2FoundBySystem = false; if (inputManager.enableKinect2) { try { Kinect2SourceManager kinect2SourceManager = FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager; if (kinect2SourceManager != null && kinect2SourceManager.GetSensor() != null && kinect2SourceManager.GetSensor().IsOpen) { // IsOpen seems to return false mostly if Kinect 2 drivers are not installed? // Debug.Log("Kinect 2 was detected by the system."); kinect2FoundBySystem = true; } } catch {} } if (RUISDisplayManager.IsHmdPositionTrackable()) { rootDevice = RUISDevice.OpenVR; } else if (inputManager.enableKinect2 && kinect2FoundBySystem) { rootDevice = RUISDevice.Kinect_2; } else if (inputManager.enableKinect) { rootDevice = RUISDevice.Kinect_1; } else if (inputManager.enablePSMove) { rootDevice = RUISDevice.PS_Move; } if (rootDevice != previousDevice) { if (previousDevice == RUISDevice.OpenVR) { Debug.LogWarning("Switched 'Master Coordinate System Sensor' from " + previousDevice + " to " + rootDevice + " " + "because OpenVR could not be accessed! Is SteamVR installed?"); } else { Debug.LogWarning("Switched 'Master Coordinate System Sensor' from " + previousDevice + " to " + rootDevice + " " + "because the former was not enabled in " + typeof(RUISInputManager) + " while the latter was!"); } } } } }
private void handleInfotexts() { GameObject infotext_Changes_saved = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes saved").gameObject; GameObject infotext_Changes_are_not_saved_in_free_version = this.transform.Find( "NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes are not saved in free version").gameObject; GameObject infotext_Changes_not_saved_yet = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes not saved yet").gameObject; GameObject infotext_Hmd_Not_Detected = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/HMD/Label - HMD not detected").gameObject; // Was "Rift not detected" GameObject infotext_Hmd_Detected = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/HMD/Label - HMD detected").gameObject; // Was "Oculus DK1 detected" if (RUISDisplayManager.IsHmdPresent()) { if (infotext_Hmd_Detected) { UILabel hmdDetectedLabel = infotext_Hmd_Detected.GetComponent <UILabel>(); if (hmdDetectedLabel) { hmdDetectedLabel.text = RUISDisplayManager.GetHmdModel() + " detected"; } } infotext_Hmd_Not_Detected.SetActive(false); infotext_Hmd_Detected.SetActive(true); } else if (infotext_Hmd_Not_Detected) { infotext_Hmd_Not_Detected.SetActive(true); infotext_Hmd_Detected.SetActive(false); } // bool isRiftConnected = false; // { // try // { // if(OVRManager.display != null) //06to08 // isRiftConnected = OVRManager.display.isPresent; //06to08 // if(OVRManager.capiHmd != null) // ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; //06to08 // // // } // catch(UnityException e) // { // Debug.LogError(e); // } // } // if(isRiftConnected && ovrHmdVersion == Ovr.HmdType.DK1) //06to08 // { // infotext_Rift_not_Detected.SetActive(false); // infotext_Oculus_DK1_detected.SetActive(true); // infotext_Oculus_DK2_detected.SetActive(false); // } // else if(isRiftConnected && (ovrHmdVersion == Ovr.HmdType.DK2 || ovrHmdVersion == Ovr.HmdType.Other)) //06to08 // { // infotext_Rift_not_Detected.SetActive(false); // infotext_Oculus_DK2_detected.SetActive(true); // infotext_Oculus_DK1_detected.SetActive(false); // } // else { // infotext_Rift_not_Detected.SetActive(true); // infotext_Oculus_DK1_detected.SetActive(false); // infotext_Oculus_DK2_detected.SetActive(false); // } if (!XmlImportExport.XmlHandlingFunctionalityAvailable()) { infotext_Changes_are_not_saved_in_free_version.SetActive(true); infotext_Changes_saved.SetActive(false); infotext_Changes_not_saved_yet.SetActive(false); } else { infotext_Changes_are_not_saved_in_free_version.SetActive(false); if (originalPSMoveIP == inputManager.PSMoveIP && originalPSMovePort == inputManager.PSMovePort && originalEnablePSMove == inputManager.enablePSMove && originalEnableKinect == inputManager.enableKinect && originalEnableKinect2 == inputManager.enableKinect2 && originalEnableJumpGesture == inputManager.jumpGestureEnabled && originalEnableHydra == inputManager.enableRazerHydra) // && originalKinectDriftCorrection == inputManager.kinectDriftCorrectionPreferred) { infotext_Changes_saved.SetActive(true); infotext_Changes_not_saved_yet.SetActive(false); } else { infotext_Changes_not_saved_yet.SetActive(true); infotext_Changes_saved.SetActive(false); } } }
/// <summary> /// Returns the object under the specified position. /// </summary> static public bool Raycast(Vector3 inPos, out RaycastHit hit) { for (int i = 0; i < mList.Count; ++i) { UICamera cam = mList[i]; // Skip inactive scripts if (!cam.enabled || !NGUITools.GetActive(cam.gameObject)) { continue; } // Convert to view space currentCamera = cam.cachedCamera; Vector3 pos = currentCamera.ScreenToViewportPoint(inPos); if (float.IsNaN(pos.x) || float.IsNaN(pos.y)) { continue; } // CORE HACK by Tuukka Takala // If it's outside the camera's viewport, do nothing // if (pos.x < 0f || pos.x > 1f || pos.y < 0f || pos.y > 1f) continue; Ray ray; // if(ruisCamera != null && ruisCamera.associatedDisplay != null) { if (UnityEngine.VR.VRSettings.enabled && currentCamera.stereoTargetEye != StereoTargetEyeMask.None) // if(ruisCamera.associatedDisplay.isHmdDisplay) { // *** TODO remove this hack when Camera.ScreenPointToRay() works again ray = RUISDisplayManager.HMDScreenPointToRay(inPos, currentCamera); } else { ray = currentCamera.ScreenPointToRay(inPos); if (ruisCamera && ruisCamera.associatedDisplay != null && ruisCamera.associatedDisplay.isObliqueFrustum) { Quaternion outerRot = ruisCamera.transform.rotation; Quaternion wallOrientation = Quaternion.LookRotation(-ruisCamera.associatedDisplay.DisplayNormal, ruisCamera.associatedDisplay.DisplayUp); // *** HACK why is this sign flip necessary to keep the menu at right place?? outerRot = new Quaternion(outerRot.x, outerRot.y, -outerRot.z, outerRot.w); ray.origin += outerRot * ruisCamera.KeystoningHeadTrackerPosition; if (displayManager) { ray.origin -= outerRot * (new Vector3(displayManager.guiX, displayManager.guiY, displayManager.guiZ)); } // ray.direction = wallOrientation * ray.direction; } } } // else // ray = currentCamera.ScreenPointToRay(inPos); // END CORE HACK // Cast a ray into the screen // Ray ray = currentCamera.ScreenPointToRay(inPos); // Raycast into the screen int mask = currentCamera.cullingMask & (int)cam.eventReceiverMask; float dist = (cam.rangeDistance > 0f) ? cam.rangeDistance : currentCamera.farClipPlane - currentCamera.nearClipPlane; // If raycasts should be clipped by panels, we need to find a panel for each hit if (cam.clipRaycasts) { RaycastHit[] hits = Physics.RaycastAll(ray, dist, mask); if (hits.Length > 1) { System.Array.Sort(hits, delegate(RaycastHit r1, RaycastHit r2) { return(r1.distance.CompareTo(r2.distance)); }); for (int b = 0, bmax = hits.Length; b < bmax; ++b) { if (IsVisible(ref hits[b])) { hit = hits[b]; return(true); } } } else if (hits.Length == 1 && IsVisible(ref hits[0])) { hit = hits[0]; return(true); } continue; } if (Physics.Raycast(ray, out hit, dist, mask)) { return(true); } } hit = mEmpty; return(false); }
public void Start() { displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; distanceFromCameraLerped = distanceFromCamera; if (disableIfOtherDevices) { RUISInputManager inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; if (inputManager) { bool otherDevices = false; string deviceNames = ""; if (inputManager.enableKinect) { deviceNames += "Kinect 1"; otherDevices = true; } if (inputManager.enableKinect2) { deviceNames += "Kinect 2"; otherDevices = true; } if (inputManager.enableRazerHydra) { if (deviceNames.Length > 0) { deviceNames += ", "; } deviceNames += "Razer Hydra"; otherDevices = true; } if (inputManager.enablePSMove) { if (deviceNames.Length > 0) { deviceNames += ", "; } deviceNames += "PS Move"; otherDevices = true; } try { var system = Valve.VR.OpenVR.System; if (system != null) { for (int i = 0; i < Valve.VR.OpenVR.k_unMaxTrackedDeviceCount; ++i) { //SteamVR_Controller.Device device = SteamVR_Controller.Input(i); //if(device != null && device.connected && device.valid && system.GetTrackedDeviceClass(device.index) == Valve.VR.ETrackedDeviceClass.Controller) //{ // if(deviceNames.Length > 0) // deviceNames += ", "; // deviceNames += "OpenVR controller"; // otherDevices = true; // break; //} } } } catch {} if (otherDevices) { Debug.Log("Disabling MouseWand GameObject '" + gameObject.name + "' because the " + "following input devices were found: " + deviceNames); gameObject.SetActive(false); } } } if (!displayManager) { Debug.LogError("RUISMouseWand requires a RUISDisplayManager in the scene!"); } }
// Ovr.HmdType ovrHmdVersion; //06to08 void Awake() { if (!scriptEnabled) { return; } inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; bool kinect2 = false; bool kinect = false; bool psmove = false; bool razer = false; // bool isRiftConnected = false; // { // try // { // // Find out if an Oculus HMD is connected // if(OVRManager.display != null) // isRiftConnected = OVRManager.display.isPresent; //06to08 // // // Find out the Oculus HMD version // if(OVRManager.capiHmd != null) // ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; //06to08 // } // catch(UnityException e) // { // Debug.LogError(e); // } // } // if (inputManager) { kinect2 = inputManager.enableKinect2; kinect = inputManager.enableKinect; psmove = inputManager.enablePSMove; razer = inputManager.enableRazerHydra; int trackerCount = 0; RUISTracker closestMatch = null; int currentMatchScore = 0; bool kinect2FoundBySystem = false; if (kinect2) { try { Kinect2SourceManager kinect2SourceManager = FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager; if (kinect2SourceManager != null && kinect2SourceManager.GetSensor() != null && kinect2SourceManager.GetSensor().IsOpen) { // IsOpen seems to return false mostly if Kinect 2 drivers are not installed? kinect2FoundBySystem = true; } } catch { } if (!kinect2FoundBySystem) { kinect2 = false; } } RUISHeadTrackerAssigner[] assigners = FindObjectsOfType(typeof(RUISHeadTrackerAssigner)) as RUISHeadTrackerAssigner[]; if (!allowMultipleAssigners && assigners.Length > 1) { Debug.LogError("Multiple active RUISHeadTrackerAssigner scripts found while 'Allow Multiple Assigners' is false: " + "Disabling all headtrackers and their child objects that are listed in the RUISHeadTrackerAssigner " + "component of '" + gameObject.name + "' object."); for (int i = 0; i < headTrackers.Capacity; ++i) { if (headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { headTrackers[i].gameObject.SetActive(false); } } return; } foreach (RUISTracker trackerScript in headTrackers) { if (trackerScript && trackerScript.gameObject.activeInHierarchy) { ++trackerCount; int foundTrackerScore = 0; // bool openVRHmdFound = false; // try // { // if(RUISDisplayManager.IsOpenVrAccessible() && Valve.VR.OpenVR.IsHmdPresent()) // *** TODO HACK Valve API // openVRHmdFound = true; // } catch{} // Give score to found head trackers if (RUISDisplayManager.IsHmdPresent() && UnityEngine.XR.XRSettings.enabled && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.OpenVR) { foundTrackerScore = 7; } else if (psmove && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.PSMove) { foundTrackerScore = 6; } else if (razer && trackerScript.isRazerBaseMobile && // Legacy: Mobile Hydra Base (custom tracker) trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && trackerScript.mobileRazerBase == RUISTracker.RazerHydraBase.InputTransform) { foundTrackerScore = 5; } else if (kinect2 && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.Kinect2) { foundTrackerScore = 4; } else if (kinect && razer && trackerScript.isRazerBaseMobile && // Legacy: Mobile Hydra Base (Kinect) trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && trackerScript.mobileRazerBase == RUISTracker.RazerHydraBase.Kinect1) { foundTrackerScore = 3; } else if (kinect && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.Kinect1) { foundTrackerScore = 2; } else if (razer && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && // Plain ol' Razer Hydra !trackerScript.isRazerBaseMobile) { foundTrackerScore = 1; } // Assign new best head tracker candidate if it is better than the previously found if (currentMatchScore < foundTrackerScore) { closestMatch = trackerScript; currentMatchScore = foundTrackerScore; } } } if (trackerCount == 0 && Application.isEditor) { Debug.LogError("No active GameObjects with RUISTracker script found from headTrackers list!"); } string positionTracker = "<None>"; string logString = ""; string names = ""; RUISCamera ruisCamera = null; if (closestMatch == null) { // Disable all but the first active head tracker from the headTrackers list logString = "Could not find a suitable head tracker with regard to " + "enabled devices in RUISInputManager!"; bool disabling = false; int leftEnabledIndex = -1; for (int i = 0; i < headTrackers.Capacity; ++i) { if (headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { if (disabling) { if (names.Length > 0) { names = names + ", "; } names = names + headTrackers[i].gameObject.name; headTrackers[i].gameObject.SetActive(false); } else { leftEnabledIndex = i; closestMatch = headTrackers[leftEnabledIndex]; positionTracker = headTrackers[leftEnabledIndex].gameObject.name; disabling = true; } } } if (leftEnabledIndex >= 0) { logString = logString + " Choosing the first head tracker in the list. Using " + positionTracker + " for tracking head position"; if (names.Length > 0) { logString = logString + ", and disabling the following: " + names; } logString = logString + ". This choice was made using a pre-selected list of " + "head trackers."; ruisCamera = headTrackers[leftEnabledIndex].gameObject.GetComponentInChildren <RUISCamera>(); } Debug.LogError(logString); } else { // Disable all but the closest match head tracker from the headTrackers list for (int i = 0; i < headTrackers.Capacity; ++i) { if (headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { if (headTrackers[i] != closestMatch) { if (names.Length > 0) { names = names + ", "; } names = names + headTrackers[i].gameObject.name; headTrackers[i].gameObject.SetActive(false); } else { positionTracker = headTrackers[i].gameObject.name; } } } logString = "Found the best head tracker with regard to enabled devices in " + "RUISInputManager! Using " + positionTracker + " for tracking head position"; if (names.Length > 0) { logString = logString + ", and disabling the following: " + names; } Debug.Log(logString + ". This choice was made using a pre-selected list of head trackers."); ruisCamera = closestMatch.gameObject.GetComponentInChildren <RUISCamera>(); if (changePivotIfNoKinect && psmove && !kinect && !kinect2 && closestMatch.headPositionInput == RUISTracker.HeadPositionSource.PSMove) { RUISCharacterController characterController = gameObject.GetComponentInChildren <RUISCharacterController>(); if (characterController != null && characterController.characterPivotType != RUISCharacterController.CharacterPivotType.MoveController) { characterController.characterPivotType = RUISCharacterController.CharacterPivotType.MoveController; characterController.moveControllerId = closestMatch.positionPSMoveID; Debug.Log("PS Move enabled and Kinect disabled. Setting " + characterController.name + "'s Character Pivot as PS Move controller #" + closestMatch.positionPSMoveID + ". PS Move position offset for this pivot is " + characterController.psmoveOffset); } } } if (ruisCamera) { if (display == null) { Debug.LogWarning("No RUISDisplay attached to the RUISHeadTrackerAssigner script!"); RUISDisplay[] displays = FindObjectsOfType(typeof(RUISDisplay)) as RUISDisplay[]; for (int i = 0; i < displays.Length; ++i) { if (displays[i].linkedCamera == null) { Debug.LogWarning("Assigned RUISCamera component from the child of " + positionTracker + " to render on " + displays[i].gameObject.name + " because that " + "RUISDisplay component's RUISCamera field was empty."); displays[i].linkedCamera = ruisCamera; break; } } } else { if (display.linkedCamera == null) { Debug.Log("Assigned RUISCamera component from the child of " + positionTracker + " to render on " + display.gameObject.name); display.linkedCamera = ruisCamera; } else { Debug.LogWarning("RUISDisplay " + display.gameObject.name + " is already connected with a " + "RUISCamera object! Leave the RUISCamera field empty in your RUISDisplay " + "component if you want RUISHeadTrackerAssigner script to automatically " + "assign a RUISCamera to your RUISDisplay."); } } } else { if (closestMatch) { Debug.LogError(positionTracker + " did not have a child with RUISCamera component, " + "and therefore it is not used to draw on any of the displays in " + "DisplayManager."); } } // If we are using Razer with a static base for head tracking, then apply onlyRazerOffset // on the parent objects of the Razer head tracker and the hand-held Razer if (closestMatch != null && razer && closestMatch.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && !closestMatch.isRazerBaseMobile) { // The parent object of the Razer head tracker must not have RUISCharacterConroller, // because that script will modify the object's position if (closestMatch.transform.parent != null && closestMatch.transform.parent.GetComponent <RUISCharacterController>() == null && (onlyRazerOffset.x != 0 || onlyRazerOffset.y != 0 || onlyRazerOffset.z != 0)) { string razerWandOffsetInfo = ""; closestMatch.transform.parent.localPosition += onlyRazerOffset; if (razerWandParent != null) { razerWandParent.localPosition += onlyRazerOffset; razerWandOffsetInfo = " and " + razerWandParent.gameObject.name + " (parent of hand-held Razer " + "Hydra)"; } Debug.Log("Applying offset of " + onlyRazerOffset + " to " + closestMatch.transform.parent.gameObject.name + " (parent of Razer Hydra head tracker)" + razerWandOffsetInfo + "."); } } // If no Razer, Kinect, or PS Move is available, then apply onlyMouseOffset // on the parent object of the head tracker that is left enabled // if( closestMatch != null && !razer && !kinect && !psmove) // { // // The parent object of the Razer head tracker must not have RUISCharacterConroller, // // because that script will modify the object's position // if( closestMatch.transform.parent != null // && closestMatch.transform.parent.GetComponent<RUISCharacterController>() == null // && (onlyMouseOffset.x != 0 || onlyMouseOffset.y != 0 || onlyMouseOffset.z != 0) ) // { // closestMatch.transform.parent.localPosition += onlyMouseOffset; // Debug.Log( "Applying offset of " + onlyMouseOffset + " to " // + closestMatch.transform.parent.gameObject.name + " (parent of assigned head tracker)."); // } // } // *** HACK TODO: Below is slightly hacky and only for HMDs with drift (i.e. Rift DK1) // Read inputConfig.xml to see if Kinect yaw drift correction for Oculus Rift should be enabled if (closestMatch != null && closestMatch.useHmdRotation && applyKinectDriftCorrectionPreference) { if (inputManager.kinectDriftCorrectionPreferred) { // Preference is to use Kinect for drift correction (if PS Move is not used for head tracking) switch (closestMatch.headPositionInput) { case RUISTracker.HeadPositionSource.Kinect1: if (!psmove && kinect) { closestMatch.externalDriftCorrection = true; closestMatch.compass = RUISTracker.CompassSource.Kinect1; } break; case RUISTracker.HeadPositionSource.RazerHydra: if (!psmove && kinect && razer) { if (closestMatch.isRazerBaseMobile) { closestMatch.externalDriftCorrection = true; closestMatch.compass = RUISTracker.CompassSource.Kinect1; } } break; } } else { // Preference is NOT to use Kinect for drift correction if (closestMatch.headPositionInput == RUISTracker.HeadPositionSource.Kinect1 && !psmove && kinect) { closestMatch.externalDriftCorrection = false; } } } } }
void Awake() { // BUTTONS // Phase: select and configure devices buttons.Add(this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Calibration").gameObject); buttons.Add(this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Display Management").gameObject); buttons.Add(this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Save Config & Restart Scene").gameObject); buttons.Add(this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Discard Configuration").gameObject); buttons.Add(this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Button - Quit Application").gameObject); // Phase: key stone configuration buttons.Add(this.transform.Find ("NGUIControls/Panel/keyStoneConfiguration/Button - Reset Keystoning").gameObject); buttons.Add(this.transform.Find ("NGUIControls/Panel/keyStoneConfiguration/Button - Save Configurations").gameObject); buttons.Add(this.transform.Find ("NGUIControls/Panel/keyStoneConfiguration/Button - Load Old Configurations").gameObject); buttons.Add(this.transform.Find ("NGUIControls/Panel/keyStoneConfiguration/Button - End Display Editing").gameObject); // CHECKBOXES checkBoxes.Add (this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Kinect/Checkbox - Use Kinect").gameObject); checkBoxes.Add (this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Kinect2/Checkbox - Use Kinect 2").gameObject); checkBoxes.Add (this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Kinect/Checkbox - Use Kinect Drift Correction").gameObject); checkBoxes.Add (this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Checkbox - Use PSMove").gameObject); checkBoxes.Add (this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Hydra/Checkbox - Use Hydra").gameObject); // TEXTFIELDS textFields.Add (this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Input - PSMove Port").gameObject); textFields.Add (this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/PSMove/Input - PSMove IP").gameObject); inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; kinectOrigGUIPos = this.transform.Find ( "NGUIControls/Panel/selectAndConfigureDevices/Kinect").transform.localPosition; kinect2OrigGUIPos = this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Kinect2").transform.localPosition; hydraOrigGUIPos = this.transform.Find ( "NGUIControls/Panel/selectAndConfigureDevices/Hydra").transform.localPosition; infotextOrigGUIPos = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts").transform.localPosition; // psMoveOrigGUIPos = this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/PSMove").transform.localPosition; // buttonsOrigGUIPos = this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons").transform.localPosition; }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(displays, true); EditorGUILayout.Space(); //if there is only one display we want to give the user the opportunity to set fullscreen if (displays.arraySize == 1) { allowResolutionDialog.boolValue = EditorGUILayout.Toggle(new GUIContent("Allow resolution dialog", "Allow the usage of the resolution dialog"), allowResolutionDialog.boolValue); if (allowResolutionDialog.boolValue) { PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Enabled; } else { PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; } } else { PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; allowResolutionDialog.boolValue = false; } if (GUILayout.Button("Add display")) { displays.arraySize++; SerializedProperty newDisplayProperty = displays.GetArrayElementAtIndex(displays.arraySize - 1); GameObject newDisplay = Instantiate(displayPrefab) as GameObject; newDisplay.name = "NewDisplay"; newDisplay.GetComponent <RUISDisplay>().xmlFilename = newDisplay.name + displays.arraySize + ".xml"; newDisplay.transform.parent = (target as RUISDisplayManager).transform; newDisplayProperty.objectReferenceValue = newDisplay; } EditorGUILayout.Space(); int removeIndex = -1; for (int i = 0; i < displays.arraySize; i++) { //DisplayEditor(displays.GetArrayElementAtIndex(i)); EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PropertyField(displays.GetArrayElementAtIndex(i)); RUISDisplay display = displays.GetArrayElementAtIndex(i).objectReferenceValue as RUISDisplay; if (display == null) { continue; } EditorGUILayout.LabelField(string.Format("{0} ({1}x{2})", display.name, display.resolutionX, display.resolutionY)); if (displays.arraySize > 1) { if (GUILayout.Button("Move up", GUILayout.ExpandWidth(false))) { MoveUp(i); } if (GUILayout.Button("Move down", GUILayout.ExpandWidth(false))) { MoveDown(i); } } if (GUILayout.Button("Delete", GUILayout.ExpandWidth(false))) { if (EditorUtility.DisplayDialog("Confirm deletion", "Are you sure you want to delete this display?", "Delete", "Cancel")) { removeIndex = i; } } EditorGUILayout.EndHorizontal(); } if (removeIndex != -1) { for (int i = removeIndex + 1; i < displays.arraySize; i++) { MoveUp(i); } displays.DeleteArrayElementAtIndex(displays.arraySize - 1); displays.arraySize--; } RUISDisplayManager displayManager = target as RUISDisplayManager; displayManager.CalculateTotalResolution(); PlayerSettings.defaultScreenWidth = displayManager.totalRawResolutionX; PlayerSettings.defaultScreenHeight = displayManager.totalRawResolutionY; //stuff for drawing the display boxes int optimalWidth = Screen.width - displayManager.displays.Count; int optimalHeight = (int)((float)displayManager.totalResolutionY / displayManager.totalResolutionX * optimalWidth); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width), GUILayout.Height(optimalHeight)); foreach (RUISDisplay display in displayManager.displays) { if (display.isStereo) { displayBoxStyle.normal.background = stereoDisplayTexture; } else { displayBoxStyle.normal.background = monoDisplayTexture; } GUILayout.Box(display.name, displayBoxStyle, GUILayout.Width(((float)display.resolutionX / displayManager.totalResolutionX) * optimalWidth), GUILayout.Height(optimalHeight * (float)display.resolutionY / displayManager.totalResolutionY)); } EditorGUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); //remove all child displays that aren't in the list anymore RUISDisplay displayToDestroy = null; foreach (RUISDisplay display in displayManager.GetComponentsInChildren <RUISDisplay>()) { if (!displayManager.displays.Contains(display)) { displayToDestroy = display; } } if (displayToDestroy) { DestroyImmediate(displayToDestroy.gameObject); } }
void Start() { colliding = false; grounded = false; // Second substitution, because RUISKinectAndMecanimCombiner might have already erased the original one and re-created it skeletonController = gameObject.GetComponentInChildren <RUISSkeletonController>(); if (skeletonController) { bodyParts.Add(skeletonController.leftFoot); bodyParts.Add(skeletonController.rightFoot); kinectPlayerId = skeletonController.playerId; bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID; } else { Debug.LogError("RUISCharacterController script in game object '" + gameObject.name + "' did not find RUISSkeletonController component from it's child objects!"); } coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem; if (stabilizingCollider) { colliderComponent = stabilizingCollider.gameObject.GetComponent <Collider>(); if (colliderComponent) { if (characterPivotType == CharacterPivotType.KinectHead || characterPivotType == CharacterPivotType.KinectTorso) { if (coordinateSystem && (inputManager.enableKinect || inputManager.enableKinect2) && !coordinateSystem.setKinectOriginToFloor) { Debug.LogWarning("It is best to enable 'setKinectOriginToFloor' from RUISCoordinateSystem " + "when using Kinect and RUISCharacterController script."); } } if (colliderComponent.material) { originalMaterial = colliderComponent.material; } else { colliderComponent.material = new PhysicMaterial(); originalMaterial = colliderComponent.material; } if (dynamicMaterial == null) { dynamicMaterial = new PhysicMaterial(); dynamicMaterial.dynamicFriction = 0; dynamicMaterial.staticFriction = 0; dynamicMaterial.frictionCombine = PhysicMaterialCombine.Minimum; if (colliderComponent.material) { dynamicMaterial.bounceCombine = originalMaterial.bounceCombine; dynamicMaterial.bounciness = originalMaterial.bounciness; // dynamicMaterial.staticFriction2 = originalMaterial.staticFriction2; // Deprecated since Unity 5.2ish // dynamicMaterial.dynamicFriction2 = originalMaterial.dynamicFriction2; // dynamicMaterial.frictionDirection2 = originalMaterial.frictionDirection2; } } } } if ((characterPivotType == CharacterPivotType.KinectHead || characterPivotType == CharacterPivotType.KinectTorso) && (skeletonController && skeletonController.playerId != kinectPlayerId)) { Debug.LogError("The 'Kinect Player Id' variable in RUISCharacterController script in gameObject '" + gameObject.name + "is different from the Kinect Player Id of the RUISSkeletonController script (located in child " + "object '" + skeletonController.gameObject.name + "). Make sure that these two values are " + "the same."); } if (useHmdPositionalTracking && !RUISDisplayManager.IsHmdPositionTrackable()) { Debug.LogError("Position tracked head-mounted display is not found, can't use it as a character pivot!"); } // try // { // bool isRiftConnected = false; // if(OVRManager.display != null) // isRiftConnected = OVRManager.display.isPresent; //06to08 // if(OVRManager.capiHmd != null) // ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; //06to08 // // if(useOculusPositionalTracking && ovrHmdVersion == Ovr.HmdType.DK1 || ovrHmdVersion == Ovr.HmdType.DKHD || ovrHmdVersion == Ovr.HmdType.None) //06to08 // { // Debug.LogError("Can't use Oculus Rift's tracked position as a pivot with Oculus Rift " + ovrHmdVersion); // useOculusPositionalTracking = false; // } // // if(useOculusPositionalTracking && !isRiftConnected) // { // Debug.LogError("Can't use Oculus Rift's tracked position as a pivot because Oculus Rift is not connected."); // useOculusPositionalTracking = false; // } // // } // catch(UnityException e) // { // useOculusPositionalTracking = false; // Debug.LogError(e); // } if (GetComponentInChildren <RUISKinectAndMecanimCombiner>()) { kinectAndMecanimCombinerExists = true; } previousPosition = transform.position; }
public override void OnInspectorGUI() { serializedObject.Update(); displayManagerLink.Update(); EditorGUILayout.PropertyField(displays, true); EditorGUILayout.Space(); //if there is only one display we want to give the user the opportunity to set fullscreen if (displays.arraySize == 1) { // allowResolutionDialog.boolValue = EditorGUILayout.Toggle(new GUIContent( "Allow Resolution Dialog", "Enables the Resolution Dialog when your " // + "standalone build starts if you have only one RUISDisplay. NOTE: In " // + "all other cases the 'Display Resolution Dialog' setting in Unity's " // + "Player Settings will be overriden with false. In those cases RUIS " // + "will attempt to force the standalone game window to have the total " // + "resolution that is the sum of your RUISDisplays arranged side-by-side."), // allowResolutionDialog.boolValue); // if (allowResolutionDialog.boolValue) // { // PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Enabled; // } // else // { // PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; // } } else { EditorStyles.textField.wordWrap = true; EditorGUILayout.TextArea("Below configuration has multiple RUISDisplays. 'Display Resolution Dialog' setting is automatically disabled " + "in Unity's Player Settings.", GUILayout.Height(60)); PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; // allowResolutionDialog.boolValue = false; } if (GUILayout.Button("Add Display")) { displays.arraySize++; SerializedProperty newDisplayProperty = displays.GetArrayElementAtIndex(displays.arraySize - 1); GameObject newDisplay = Instantiate(displayPrefab) as GameObject; newDisplay.name = "NewDisplay"; newDisplay.GetComponent <RUISDisplay>().xmlFilename = newDisplay.name + displays.arraySize + ".xml"; newDisplay.transform.parent = (target as RUISDisplayManager).transform; newDisplayProperty.objectReferenceValue = newDisplay; } EditorGUILayout.Space(); int removeIndex = -1; for (int i = 0; i < displays.arraySize; i++) { //DisplayEditor(displays.GetArrayElementAtIndex(i)); EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PropertyField(displays.GetArrayElementAtIndex(i)); RUISDisplay display = displays.GetArrayElementAtIndex(i).objectReferenceValue as RUISDisplay; if (display == null) { continue; } EditorGUILayout.LabelField(string.Format("{0} ({1}x{2})", display.name, display.resolutionX, display.resolutionY)); if (displays.arraySize > 1) { if (GUILayout.Button("Move Up", GUILayout.ExpandWidth(false))) { MoveUp(i); } if (GUILayout.Button("Move Down", GUILayout.ExpandWidth(false))) { MoveDown(i); } } if (GUILayout.Button("Delete", GUILayout.ExpandWidth(false))) { if (EditorUtility.DisplayDialog("Confirm deletion", "Are you sure you want to delete this display?", "Delete", "Cancel")) { removeIndex = i; } } EditorGUILayout.EndHorizontal(); } if (removeIndex != -1) { for (int i = removeIndex + 1; i < displays.arraySize; i++) { MoveUp(i); } displays.DeleteArrayElementAtIndex(displays.arraySize - 1); displays.arraySize--; } RUISDisplayManager displayManager = target as RUISDisplayManager; displayManager.CalculateTotalResolution(); PlayerSettings.defaultScreenWidth = displayManager.totalRawResolutionX; PlayerSettings.defaultScreenHeight = displayManager.totalRawResolutionY; //stuff for drawing the display boxes int optimalWidth = Screen.width - displayManager.displays.Count; int optimalHeight = (int)((float)displayManager.totalResolutionY / displayManager.totalResolutionX * optimalWidth); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(GUILayout.Width(Screen.width), GUILayout.Height(optimalHeight)); foreach (RUISDisplay display in displayManager.displays) { if (display.isStereo) { displayBoxStyle.normal.background = stereoDisplayTexture; } else { displayBoxStyle.normal.background = monoDisplayTexture; } GUILayout.Box(display.name, displayBoxStyle, GUILayout.Width(((float)display.resolutionX / displayManager.totalResolutionX) * optimalWidth), GUILayout.Height(optimalHeight * (float)display.resolutionY / displayManager.totalResolutionY)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Display With RUIS Menu:"); guiDisplayChoices = new List <string>(); for (int i = 0; i < displayManager.displays.Count; ++i) { guiDisplayChoices.Add(i + " " + displayManager.displays[i].name); } //MonoBehaviour.print(guiDisplayChoiceLink + ":" + guiDisplayChoices.Count); if (guiDisplayChoiceLink.intValue >= guiDisplayChoices.Count) { guiDisplayChoiceLink.intValue = 0; } guiDisplayChoiceLink.intValue = EditorGUILayout.Popup(guiDisplayChoiceLink.intValue, guiDisplayChoices.ToArray()); EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(ruisMenuPrefab); EditorGUILayout.LabelField("RUIS Menu Local Coordinates:"); EditorGUILayout.PropertyField(guiX, new GUIContent("X", "X-offset from camera")); EditorGUILayout.PropertyField(guiY, new GUIContent("Y", "Y-offset from camera")); EditorGUILayout.PropertyField(guiZ, new GUIContent("Z", "Z-offset from camera")); EditorGUILayout.Space(); EditorGUILayout.LabelField("RUIS Menu Scale:"); EditorGUILayout.PropertyField(guiScaleX, new GUIContent("X-scale", "Scales menu horizontally")); EditorGUILayout.PropertyField(guiScaleY, new GUIContent("Y-scale", "Scales menu vertically")); EditorGUILayout.Space(); EditorGUILayout.PropertyField(hideMouseOnPlay, new GUIContent("Hide Mouse On Play", "Operating system mouse cursor will be hidden")); EditorGUILayout.Space(); EditorGUILayout.PropertyField(menuCursorPrefab, new GUIContent("Menu Cursor Prefab", "The prefab that will be instantiated when RUIS Menu is " + "invoked (ESC key)")); menuLayer.intValue = EditorGUILayout.LayerField(new GUIContent("Menu Layer", "RUIS Menu mouse cursor ray is cast against objects on this layer only"), menuLayer.intValue); serializedObject.ApplyModifiedProperties(); displayManagerLink.ApplyModifiedProperties(); //remove all child displays that aren't in the list anymore RUISDisplay displayToDestroy = null; foreach (RUISDisplay display in displayManager.GetComponentsInChildren <RUISDisplay>()) { if (!displayManager.displays.Contains(display)) { displayToDestroy = display; } } if (displayToDestroy) { DestroyImmediate(displayToDestroy.gameObject); } }
// Use this for initialization void Start() { try { Input.GetButtonDown("RUISMenu"); } catch (UnityException) { ruisMenuButtonDefined = false; } inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; enablePSMove = inputManager.enablePSMove; psMoveIP = inputManager.PSMoveIP; psMovePort = inputManager.PSMovePort; jumpGesture = FindObjectOfType(typeof(RUISJumpGestureRecognizer)) as RUISJumpGestureRecognizer; displayManager = FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager; riftDisplay = displayManager.GetOculusRiftDisplay(); // TODO: This menu should work with any stereo view, not just Rift. riftDisplay.linkedCamera is null when Rift is disabled. if (oculusRiftMenu && riftDisplay && riftDisplay.linkedCamera ) { windowRect = new Rect(riftDisplay.linkedCamera.leftCamera.pixelRect.x + riftDisplay.resolutionX / 4 - 100, riftDisplay.resolutionY / 2 - 220, 250, 250); } SaveInputChanges(); }
private Vector3 GetPivotPositionInTrackerCoordinates() { if (useHmdPositionalTracking && RUISDisplayManager.IsHmdPositionTrackable() && coordinateSystem) { if (coordinateSystem.applyToRootCoordinates) { return(coordinateSystem.ConvertLocation(coordinateSystem.GetHmdRawPosition(), RUISDevice.OpenVR)); } else { return(coordinateSystem.GetHmdRawPosition()); } } else { switch (characterPivotType) { case CharacterPivotType.KinectHead: { if ((bodyTrackingDeviceID == RUISSkeletonManager.kinect2SensorID && !inputManager.enableKinect2) || (bodyTrackingDeviceID == RUISSkeletonManager.kinect1SensorID && !inputManager.enableKinect)) { break; } if (skeletonManager && skeletonManager.skeletons[bodyTrackingDeviceID, kinectPlayerId] != null) { if (skeletonController) // Add root speed scaling { return(Vector3.Scale(skeletonManager.skeletons[bodyTrackingDeviceID, kinectPlayerId].head.position, skeletonController.rootSpeedScaling)); } else { return(skeletonManager.skeletons[bodyTrackingDeviceID, kinectPlayerId].head.position); } } break; } case CharacterPivotType.KinectTorso: { if ((bodyTrackingDeviceID == RUISSkeletonManager.kinect2SensorID && !inputManager.enableKinect2) || (bodyTrackingDeviceID == RUISSkeletonManager.kinect1SensorID && !inputManager.enableKinect)) { break; } if (skeletonManager && skeletonManager.skeletons[bodyTrackingDeviceID, kinectPlayerId] != null) { if (skeletonController) // Add root speed scaling { return(Vector3.Scale(skeletonManager.skeletons[bodyTrackingDeviceID, kinectPlayerId].torso.position, skeletonController.rootSpeedScaling)); } else { return(skeletonManager.skeletons[bodyTrackingDeviceID, kinectPlayerId].torso.position); } } break; } case CharacterPivotType.MoveController: { if (!inputManager.enablePSMove) { break; } //if(inputManager.GetMoveWand(moveControllerId)) // return inputManager.GetMoveWand(moveControllerId).handlePosition; break; } } } if (skeletonController != null) { return(skeletonController.transform.localPosition); } else { return(Vector3.zero); } }
// public RUISDisplay GetHmdDisplay() // { // foreach(RUISDisplay display in displays) // { // if(display.linkedCamera && display.isHmdDisplay) // { // return display; // } // } // // return null; // } private void InitRUISMenu(GameObject ruisMenuPrefab, int guiDisplayChoice) { if (ruisMenuPrefab == null) { return; } // HACK: displays is a list and accessing components by index might break if we modify the list in run-time if (displays.Count <= guiDisplayChoice) { Debug.LogError("displays.Count is too small: " + displays.Count + ", because guiDisplayChoice == " + guiDisplayChoice + ". Add more RUISDisplays or change the 'Display With RUIS Menu' field in " + typeof(RUISDisplayManager), this); return; } if (displays[guiDisplayChoice] == null || displays[guiDisplayChoice].GetComponent <RUISDisplay>() == null || displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera == null) { return; } GameObject ruisMenu = Instantiate(ruisMenuPrefab) as GameObject; if (ruisMenu == null) { return; } if (menuLayer == -1) { Debug.LogError("Could not find layer '" + LayerMask.LayerToName(menuLayer) + "', the RUIS menu cursor will not work without this layer! " + "The prefab '" + ruisMenuPrefab.name + "' and its children should be on this layer."); } if (!displays[guiDisplayChoice].GetComponent <RUISDisplay>().isStereo /* && !displays[guiDisplayChoice].GetComponent<RUISDisplay>().enableOculusRift */) { if (displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.centerCamera) { displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.centerCamera.gameObject.AddComponent <UICamera>(); } else { Debug.LogError("The " + typeof(RUISDisplay) + " that was assigned with 'RUIS Menu Prefab' in " + typeof(RUISDisplayManager) + " has an 'Attached Camera' " + " whose centerCamera is null for some reason! Can't create UICamera."); } } else { if (displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.rightCamera) { displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.rightCamera.gameObject.AddComponent <UICamera>(); } else { Debug.LogError("The " + typeof(RUISDisplay) + " that was assigned with 'RUIS Menu Prefab' in " + typeof(RUISDisplayManager) + " has an 'Attached Camera' " + " whose rightCamera is null for some reason! Can't create UICamera."); } if (displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.leftCamera) { displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.leftCamera.gameObject.AddComponent <UICamera>(); } else { Debug.LogError("The " + typeof(RUISDisplay) + " that was assigned with 'RUIS Menu Prefab' in " + typeof(RUISDisplayManager) + " has an 'Attached Camera' " + " whose leftCamera is null for some reason! Can't create UICamera."); } } UICamera[] NGUIcameras = displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.GetComponentsInChildren <UICamera>(); foreach (UICamera camera in NGUIcameras) { camera.eventReceiverMask = LayerMask.GetMask(LayerMask.LayerToName(menuLayer)); } string primaryMenuParent = displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.centerCameraName; string secondaryMenuParent = displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.rightCameraName; string tertiaryMenuParent = displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.leftCameraName; if (displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.centerCamera && !(displays[guiDisplayChoice].GetComponent <RUISDisplay>().isStereo&& RUISDisplayManager.IsHmdPresent() && displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.centerCamera.stereoTargetEye != StereoTargetEyeMask.None)) { ruisMenu.transform.parent = displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.centerCamera.transform; } else { if (displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.rightCamera) { ruisMenu.transform.parent = displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.rightCamera.transform; } else { if (displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.leftCamera) { ruisMenu.transform.parent = displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.leftCamera.transform; } else { // Debug.LogError( "Could not find any of the following gameObjects under " // + displays[guiDisplayChoice].GetComponent<RUISDisplay>().linkedCamera.gameObject.name // + ": " + primaryMenuParent + ", " + secondaryMenuParent + ", " + tertiaryMenuParent + ". RUIS Menu will be parented " // + "directly under " + displays[guiDisplayChoice].GetComponent<RUISDisplay>().linkedCamera.gameObject.name + "."); // ruisMenu.transform.parent = displays[guiDisplayChoice].GetComponent<RUISDisplay>().linkedCamera.transform; Debug.LogError("Can't parent RUIS Menu Prefab under the correct Transform because the " + typeof(RUISCamera) + " in gameObject " + displays[guiDisplayChoice].GetComponent <RUISDisplay>().linkedCamera.gameObject + " has null value for centerCamera, " + "leftCamera, and rightCamera."); } } } ruisMenu.transform.localRotation = Quaternion.identity; ruisMenu.transform.localPosition = new Vector3(guiX, guiY, guiZ); if (ruisMenu.GetComponent <RUISMenuNGUI>()) { ruisMenu.GetComponent <RUISMenuNGUI>().Hide3DGUI(); } }