Exemple #1
0
        private static JSONObject LoadProjectManifest()
        {
            string     manifestString = File.ReadAllText(RegistryToolSettings.Instance().ProjectManifestPath);
            JSONObject manifestJson   = JSONNode.Parse(manifestString).AsObject;

            return(manifestJson);
        }
Exemple #2
0
            public override void OnPreferenceGUI()
            {
                const string title = "OpenVR";

                if (canSupport)
                {
                    support = m_foldouter.ShowFoldoutButtonOnToggleEnabled(new GUIContent(title, "VIVE, VIVE Pro, VIVE Pro Eye, VIVE Cosmos\nOculus Rift, Oculus Rift S, Windows MR"), support);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    Foldouter.ShowFoldoutBlank();

                    if (activeBuildTargetGroup != BuildTargetGroup.Standalone)
                    {
                        GUI.enabled = false;
                        ShowToggle(new GUIContent(title, "Standalone platform required."), false, GUILayout.Width(230f));
                        GUI.enabled = true;
                        GUILayout.FlexibleSpace();
                        ShowSwitchPlatformButton(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
                    }
#if UNITY_2019_3_OR_NEWER
                    else if (!PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME))
                    {
                        GUI.enabled = false;
                        ShowToggle(new GUIContent(title, "OpenVR XR Plugin package required."), false, GUILayout.Width(230f));
                        GUI.enabled = true;
                        GUILayout.FlexibleSpace();

                        bool hasValveRegistryAdded = RegistryToolSettings.IsRegistryExists(ValveRegistry);
                        if (hasValveRegistryAdded)
                        {
                            ShowAddPackageButton("OpenVR XR Plugin", OPENVR_XR_PACKAGE_NAME);
                        }
                        else
                        {
                            if (GUILayout.Button(new GUIContent("Add Valve Registry")))
                            {
                                bool result = EditorUtility.DisplayDialog(
                                    "Add Valve Registry",
                                    "Do you want to add Valve registry to your project?\n\nBy adding the Valve registry (" + ValveRegistry.url + ") in your 'Packages/manifest.json', VIU can install OpenVR XR Plugin for you.\n\nIn addition, you can discover, install, update or remove the packages from Valve in the package manager window later.",
                                    "Add",
                                    "Cancel");

                                if (result)
                                {
                                    RegistryToolSettings.AddRegistry(ValveRegistry);
                                }
                            }
                        }
                    }
#endif
#if !UNITY_2020_1_OR_NEWER
                    else if (!PackageManagerHelper.IsPackageInList(OPENVR_PACKAGE_NAME))
                    {
                        GUI.enabled = false;
                        ShowToggle(new GUIContent(title, "OpenVR (Desktop) package required."), false, GUILayout.Width(230f));
                        GUI.enabled = true;
                        GUILayout.FlexibleSpace();
                        ShowAddPackageButton("OpenVR (Desktop)", OPENVR_PACKAGE_NAME);
                    }
#endif
                    else if (!VRModule.isSteamVRPluginDetected)
                    {
                        GUI.enabled = false;
                        ShowToggle(new GUIContent(title, "SteamVR Plugin required."), false, GUILayout.Width(230f));
                        GUI.enabled = true;
                        GUILayout.FlexibleSpace();
                        ShowUrlLinkButton(URL_STEAM_VR_PLUGIN);
                    }

                    GUILayout.EndHorizontal();
                }

                if (support && m_foldouter.isExpended)
                {
                    if (support && VRModule.isSteamVRPluginDetected)
                    {
                        EditorGUI.BeginChangeCheck();
                    }
                    else
                    {
                        GUI.enabled = false;
                    }
                    {
                        EditorGUI.indentLevel += 2;

                        VIUSettings.autoLoadExternalCameraConfigOnStart = EditorGUILayout.ToggleLeft(new GUIContent("Load Config and Enable External Camera on Start", "You can also load config by calling ExternalCameraHook.LoadConfigFromFile(path) in script."), VIUSettings.autoLoadExternalCameraConfigOnStart);
                        if (!VIUSettings.autoLoadExternalCameraConfigOnStart && support)
                        {
                            GUI.enabled = false;
                        }
                        {
                            EditorGUI.indentLevel++;

                            EditorGUI.BeginChangeCheck();
                            VIUSettings.externalCameraConfigFilePath = EditorGUILayout.DelayedTextField(new GUIContent("Config Path"), VIUSettings.externalCameraConfigFilePath);
                            if (string.IsNullOrEmpty(VIUSettings.externalCameraConfigFilePath))
                            {
                                VIUSettings.externalCameraConfigFilePath = VIUSettings.EXTERNAL_CAMERA_CONFIG_FILE_PATH_DEFAULT_VALUE;
                                EditorGUI.EndChangeCheck();
                            }
                            else if (EditorGUI.EndChangeCheck() && VIUSettings.externalCameraConfigFilePath.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
                            {
                                VIUSettings.externalCameraConfigFilePath = VIUSettings.EXTERNAL_CAMERA_CONFIG_FILE_PATH_DEFAULT_VALUE;
                            }
                            // Create button that writes default config file
                            if (VIUSettings.autoLoadExternalCameraConfigOnStart && support && !File.Exists(VIUSettings.externalCameraConfigFilePath))
                            {
                                if (support && VRModule.isSteamVRPluginDetected)
                                {
                                    s_guiChanged |= EditorGUI.EndChangeCheck();
                                }
                                ShowCreateExCamCfgButton();
                                if (support && VRModule.isSteamVRPluginDetected)
                                {
                                    EditorGUI.BeginChangeCheck();
                                }
                            }

                            EditorGUI.indentLevel--;
                        }
                        if (!VIUSettings.autoLoadExternalCameraConfigOnStart && support)
                        {
                            GUI.enabled = true;
                        }

                        VIUSettings.enableExternalCameraSwitch = EditorGUILayout.ToggleLeft(new GUIContent("Enable External Camera Switch", VIUSettings.EX_CAM_UI_SWITCH_TOOLTIP), VIUSettings.enableExternalCameraSwitch);
                        if (!VIUSettings.enableExternalCameraSwitch && support)
                        {
                            GUI.enabled = false;
                        }
                        {
                            EditorGUI.indentLevel++;

                            VIUSettings.externalCameraSwitchKey         = (KeyCode)EditorGUILayout.EnumPopup("Switch Key", VIUSettings.externalCameraSwitchKey);
                            VIUSettings.externalCameraSwitchKeyModifier = (KeyCode)EditorGUILayout.EnumPopup("Switch Key Modifier", VIUSettings.externalCameraSwitchKeyModifier);

                            EditorGUI.indentLevel--;
                        }
                        if (!VIUSettings.enableExternalCameraSwitch && support)
                        {
                            GUI.enabled = true;
                        }

                        EditorGUI.indentLevel -= 2;
                    }
                    if (support && VRModule.isSteamVRPluginDetected)
                    {
                        s_guiChanged |= EditorGUI.EndChangeCheck();
                    }
                    else
                    {
                        GUI.enabled = true;
                    }
                }

                if (support && !VRModule.isSteamVRPluginDetected)
                {
                    EditorGUI.indentLevel += 2;

#if VIU_XR_GENERAL_SETTINGS
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("For now, to get access to controllers and other forms of input, you will need to install the beta version of the SteamVR Unity Plugin.", MessageType.Warning);

                    s_warningHeight = Mathf.Max(s_warningHeight, GUILayoutUtility.GetLastRect().height);

                    GUILayout.BeginVertical(GUILayout.Height(s_warningHeight));
                    GUILayout.FlexibleSpace();
                    ShowUrlLinkButton(URL_STEAM_VR_PLUGIN_BETA, "Get SteamVR Plugin (beta)");
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
#else
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("External-Camera(Mix-Reality), animated controller model" +
                                            ", VIVE Controller haptics(vibration)" +
#if UNITY_2017_1_OR_NEWER
                                            ", VIVE Tracker USB/Pogo-pin input" +
#else
                                            ", VIVE Tracker device" +
#endif
                                            " NOT supported! " +
#if VIU_PACKAGE
                                            "Install SteamVR Plugin 2.4.0 or newer to get support."
#else
                                            "Install SteamVR Plugin to get support."
#endif
                                            , MessageType.Warning);

                    s_warningHeight = Mathf.Max(s_warningHeight, GUILayoutUtility.GetLastRect().height);

                    GUILayout.BeginVertical(GUILayout.Height(s_warningHeight));
                    GUILayout.FlexibleSpace();
                    ShowUrlLinkButton(URL_STEAM_VR_PLUGIN, "Get SteamVR Plugin");
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
#endif
                    EditorGUI.indentLevel -= 2;
                }
            }
Exemple #3
0
        private static void Save(JSONObject newJson)
        {
            string jsonString = newJson.ToString(JSON_INDENT_SPACE_COUNT);

            File.WriteAllText(RegistryToolSettings.Instance().ProjectManifestPath, jsonString);
        }