Esempio n. 1
0
    private bool Export()
    {
        string filename = EditorUtility.SaveFilePanel("Export Input Configuration", null, "inputConfig", "xml");

        if (filename.Length != 0)
        {
            return(inputConfig.Export(filename));
        }
        else
        {
            return(false);
        }
    }
Esempio n. 2
0
    void DrawWindow(int windowId)
    {
        Vector2 elementSize;
        float   elementHeight = 10;

        elementSize = GUI.skin.GetStyle("button").CalcSize(new GUIContent("X"));
        float additionalSpacing = 0.5f * elementSize.y;

        GUILayout.Space(additionalSpacing);

        switch (menuState)
        {
        case MenuState.Main:
            inputManager.enablePSMove = GUILayout.Toggle(inputManager.enablePSMove, "Use PS Move");


            elementSize = GUI.skin.GetStyle("textField").CalcSize(new GUIContent("999099909990999"));
            GUI.enabled = inputManager.enablePSMove;
            GUILayout.BeginHorizontal();
            GUILayout.Label("IP:");
            string ipText = GUILayout.TextField(inputManager.PSMoveIP, GUILayout.Width(elementSize.x));
            GUILayout.EndHorizontal();
            ipText = Regex.Replace(ipText, @"[^0-9 .]", "");
            inputManager.PSMoveIP = ipText;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Port:");
            string portText = GUILayout.TextArea(inputManager.PSMovePort.ToString(), GUILayout.Width(elementSize.x));
            GUILayout.EndHorizontal();
            portText = Regex.Replace(portText, @"[^0-9 ]", "");
            inputManager.PSMovePort = int.Parse(portText);
            GUI.enabled             = true;

            inputManager.enableKinect = GUILayout.Toggle(inputManager.enableKinect, "Use Kinect");

            GUI.enabled = inputManager.enablePSMove && inputManager.enableKinect;

            GUI.backgroundColor = originalBackground;
            if (GUILayout.Button("Calibrate PS Move & Kinect (and Save)"))
            {
                inputManager.Export(inputManager.filename);
                SaveInputChanges();

                DontDestroyOnLoad(this);

                Debug.Log("Loading calibration screen.");

                gameObject.transform.parent = null;

                previousSceneId = Application.loadedLevel;

                menuState = MenuState.Calibrating;

                isShowing = false;

                Application.LoadLevel("calibration");
            }

            GUI.enabled = true;


            inputManager.enableRazerHydra = GUILayout.Toggle(inputManager.enableRazerHydra, "Use Hydra");

            GUI.backgroundColor = originalBackground;

            gridStyle = new GUIStyle(GUI.skin.button);
            gridStyle.onActive.textColor = darkGreen;
            gridStyle.onNormal.textColor = darkGreen;

            GUILayout.Space(additionalSpacing);
            GUI.color = lightGrey;
            GUILayout.Label("Rift magnetometer drift correction:");
            GUI.color = Color.white;
            string[] magnetometerNames = System.Enum.GetNames(typeof(RUISInputManager.RiftMagnetometer));
            inputManager.riftMagnetometerMode = (RUISInputManager.RiftMagnetometer)GUILayout.SelectionGrid((int)inputManager.riftMagnetometerMode,
                                                                                                           magnetometerNames, 1, gridStyle);

            GUILayout.Space(additionalSpacing);

            if (inputManager.enableKinect && !inputManager.enablePSMove)
            {
                if (inputManager.kinectDriftCorrectionPreferred)
                {
                    GUI.backgroundColor = Color.green;
                }
                elementSize = GUI.skin.GetStyle("label").CalcSize(new GUIContent("XX"));
                GUILayout.BeginHorizontal();
                GUILayout.Space(elementSize.x + 0.5f * GUI.skin.label.margin.vertical);
                inputManager.kinectDriftCorrectionPreferred = GUILayout.Toggle(inputManager.kinectDriftCorrectionPreferred, " Use Kinect For Drift Correction");
                GUILayout.EndHorizontal();
                GUI.backgroundColor = originalBackground;
            }
            else
            {
                elementSize   = GUI.skin.GetStyle("toggle").CalcSize(new GUIContent(" Use Kinect For Drift Correction"));
                elementHeight = GUI.skin.GetStyle("toggle").CalcHeight(new GUIContent(" Use Kinect For Drift Correction"), elementSize.x);
                GUILayout.Space(elementHeight + 0.5f * GUI.skin.toggle.margin.vertical);
            }

            GUILayout.Space(2 * additionalSpacing);

            if (GUILayout.Button("Display Management"))
            {
                SwitchKeystoneEditingState();
                //ToggleKeystoneGridState();
                menuState = MenuState.EditingDisplays;
            }

            GUI.enabled = UnsavedChanges();
            if (GUILayout.Button("     Save Configuration & Restart Scene"))
            {
                inputManager.Export(inputManager.filename);
                SaveInputChanges();
                Application.LoadLevel(Application.loadedLevel);
            }
            if (GUILayout.Button("Discard Configuration"))
            {
                menuState = MenuState.Main;
                DiscardInputChanges();
                isShowing = !isShowing;
            }
            GUI.enabled = true;

            /*if (GUILayout.Button("Display Configuration"))
             * {
             *  SwitchKeystoneEditingState();
             *  menuState = MenuState.EditingDisplays;
             * }
             * if (GUILayout.Button("Input Configuration"))
             * {
             *  menuState = MenuState.EditingInputConfiguration;
             * }
             *              if(GUILayout.Button ("Resize Screen")){
             *                      (FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager).UpdateDisplays();
             *              }*/
            if (GUILayout.Button("Quit Application"))
            {
                Application.Quit();
            }
            break;

        case MenuState.Calibrating:
            if (GUILayout.Button("End Calibration"))
            {
                Destroy(this.gameObject);

                Application.LoadLevel(previousSceneId);
            }
            break;

        case MenuState.EditingDisplays:
            if (GUILayout.Button("Reset Keystoning"))
            {
                foreach (RUISKeystoningConfiguration keystoningConfiguration in FindObjectsOfType(typeof(RUISKeystoningConfiguration)) as RUISKeystoningConfiguration[])
                {
                    keystoningConfiguration.ResetConfiguration();
                }
            }
            if (GUILayout.Button("Save Configurations"))
            {
                (FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager).SaveDisplaysToXML();
            }
            if (GUILayout.Button("Load Old Configurations"))
            {
                (FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager).LoadDisplaysFromXML();
            }
            if (GUILayout.Button("End Display Editing"))
            {
                SwitchKeystoneEditingState();
                menuState = MenuState.Main;
            }
            break;

        case MenuState.EditingInputConfiguration:

            break;
        }

        originalBackground = GUI.backgroundColor;
        GUI.DragWindow();
    }
Esempio n. 3
0
    void buttonPressed(GameObject clickedGameObject)
    {
        switch (currentMenuState)
        {
        case RUISMenuStates.selectAndConfigureDevices:
            switch (clickedGameObject.name)
            {
            case "Button - Calibration":
                calibrationReady = false;
                menuIsVisible    = false;
                inputManager.Export(inputManager.filename);
                calibrationDropDownSelection = this.transform.Find(
                    "NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection;

                if (calibrationDropDownSelection.Contains("Oculus"))                                // TODO: Not the best way to be sure that we will calibrate Oculus Rift
                {
                    enableOculusPositionalTracking();
                }

                SaveInputChanges();
                DontDestroyOnLoad(this);
                this.transform.parent = null;
                currentMenuState      = RUISMenuStates.calibration;
                previousSceneId       = Application.loadedLevel;
                Hide3DGUI();
                Application.LoadLevel("calibration");
                break;

            case "Button - Display Management":
                toggleKeystoneConfigurationLayer();
                currentMenuState = RUISMenuStates.keyStoneConfiguration;
                break;

            case "Button - Save Config & Restart Scene":
                inputManager.Export(inputManager.filename);
                SaveInputChanges();
                Application.LoadLevel(Application.loadedLevel);
                break;

            case "Button - Discard Configuration":
                DiscardInputChanges();
                break;

            case "Button - Quit Application":
                if (!Application.isEditor)
                {
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
                else
                {
                    Application.Quit();
                }
                break;
            }
            break;

        case RUISMenuStates.keyStoneConfiguration:
            switch (clickedGameObject.name)
            {
            case "Button - Reset Keystoning":
                foreach (RUISKeystoningConfiguration keystoningConfiguration in FindObjectsOfType(typeof(RUISKeystoningConfiguration)) as RUISKeystoningConfiguration[])
                {
                    keystoningConfiguration.ResetConfiguration();
                }
                break;

            case "Button - Save Configurations":
                (FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager).SaveDisplaysToXML();
                break;

            case "Button - Load Old Configurations":
                (FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager).LoadDisplaysFromXML();
                break;

            case "Button - End Display Editing":
                toggleKeystoneConfigurationLayer();
                currentMenuState = RUISMenuStates.selectAndConfigureDevices;
                break;
            }
            break;
        }
    }
Esempio n. 4
0
//	void enableOculusPositionalTracking()
//	{
//		OVRManager ovrManager = FindObjectOfType<OVRManager>();
//		if(ovrManager)
//			ovrManager.usePositionTracking = true;
//		if(OVRManager.tracker != null)
//			OVRManager.tracker.isEnabled = true;
//	}

    void buttonPressed(GameObject clickedGameObject)
    {
        switch (currentMenuState)
        {
        case RUISMenuStates.selectAndConfigureDevices:
            switch (clickedGameObject.name)
            {
            case "Button - Calibration":
                calibrationReady = false;
                menuIsVisible    = false;
                inputManager.Export(inputManager.filename);
                calibrationDropDownSelection = this.transform.Find(
                    "NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection;

//						if(calibrationDropDownSelection.Contains("Oculus")) // *** HACK TODO: Not the best way to be sure that we will calibrate Oculus Rift
//									enableOculusPositionalTracking();

                SaveInputChanges();
                this.transform.parent = null;
//						DontDestroyOnLoad(this);
                currentMenuState = RUISMenuStates.calibration;
//						previousSceneId = Application.loadedLevel;
                Hide3DGUI();

                // NOTE: The calibrationDropDownSelection determines the device pair to be calibrated, and it must follow the format "Device A - Device B"
                //       The string must correspond the options in the Awake() method of RUISCoordinateCalibration script

                // Trim out the " (HMD)" and " (controller)" from the OpenVR option string
//						string dropDownSelectionSubstring = this.calibrationDropDownSelection;
//						if(dropDownSelectionSubstring != null)
//						{
//							int stringIndex = dropDownSelectionSubstring.IndexOf("OpenVR (");
//							if(stringIndex >= 0 && stringIndex + 6 < dropDownSelectionSubstring.Length)
//							{
//									dropDownSelectionSubstring = dropDownSelectionSubstring.Substring(0, stringIndex + 6);
//							}
//						}

                // Hacky way to pass information between loading scenes
                RUISCalibrationProcessSettings.isCalibrating      = true;
                RUISCalibrationProcessSettings.devicePair         = this.calibrationDropDownSelection;                         // dropDownSelectionSubstring
                RUISCalibrationProcessSettings.previousSceneId    = Application.loadedLevel;
                RUISCalibrationProcessSettings.enablePSMove       = inputManager.enablePSMove;
                RUISCalibrationProcessSettings.enableKinect       = inputManager.enableKinect;
                RUISCalibrationProcessSettings.enableKinect2      = inputManager.enableKinect2;
                RUISCalibrationProcessSettings.jumpGestureEnabled = inputManager.jumpGestureEnabled;
                RUISCalibrationProcessSettings.enableRazerHydra   = inputManager.enableRazerHydra;
                RUISCalibrationProcessSettings.PSMoveIP           = inputManager.PSMoveIP;
                RUISCalibrationProcessSettings.PSMovePort         = inputManager.PSMovePort;
                if (coordinateSystem)
                {
                    RUISCalibrationProcessSettings.yawOffset      = coordinateSystem.yawOffset;
                    RUISCalibrationProcessSettings.positionOffset = coordinateSystem.positionOffset;
                    RUISCalibrationProcessSettings.originalMasterCoordinateSystem = coordinateSystem.rootDevice;
                }

                Application.LoadLevel("calibration");
                break;

            case "Button - Display Management":
                toggleKeystoneConfigurationLayer();
                currentMenuState = RUISMenuStates.keyStoneConfiguration;
                break;

            case "Button - Save Config & Restart Scene":
                inputManager.Export(inputManager.filename);
                SaveInputChanges();
                Application.LoadLevel(Application.loadedLevel);
                break;

            case "Button - Discard Configuration":
                DiscardInputChanges();
                break;

            case "Button - Quit Application":
                if (!Application.isEditor)
                {
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
                else
                {
                    Application.Quit();
                }
                break;
            }
            break;

        case RUISMenuStates.keyStoneConfiguration:
            switch (clickedGameObject.name)
            {
            case "Button - Reset Keystoning":
                foreach (RUISKeystoningConfiguration keystoningConfiguration in FindObjectsOfType(typeof(RUISKeystoningConfiguration)) as RUISKeystoningConfiguration[])
                {
                    keystoningConfiguration.ResetConfiguration();
                }
                break;

            case "Button - Save Configurations":
                (FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager).SaveDisplaysToXML();
                break;

            case "Button - Load Old Configurations":
                (FindObjectOfType(typeof(RUISDisplayManager)) as RUISDisplayManager).LoadDisplaysFromXML();
                break;

            case "Button - End Display Editing":
                toggleKeystoneConfigurationLayer();
                currentMenuState = RUISMenuStates.selectAndConfigureDevices;
                break;
            }
            break;
        }
    }