Exemplo n.º 1
0
        private void ApplySelectedConfiguration(MixedRealityProjectConfiguration selectedMRConfiguration)
        {
            bool             remoting = false;
            BuildTargetGroup targetGroup;

            switch (selectedMRConfiguration)
            {
            case MixedRealityProjectConfiguration.RunNativelyOnHL2:
                targetGroup = BuildTargetGroup.WSA;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
                EditorUserBuildSettings.wsaBuildAndRunDeployTarget = WSABuildAndRunDeployTarget.DevicePortal;
                EditorUserBuildSettings.wsaArchitecture            = "ARM64";
                break;

            case MixedRealityProjectConfiguration.RunNativelyOnPCVR:
                targetGroup = BuildTargetGroup.Standalone;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
                break;

            case MixedRealityProjectConfiguration.RunRemotelyOnUWP:
                remoting    = true;
                targetGroup = BuildTargetGroup.WSA;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.WSA, BuildTarget.WSAPlayer);
                EditorUserBuildSettings.wsaBuildAndRunDeployTarget = WSABuildAndRunDeployTarget.LocalMachine;
                EditorUserBuildSettings.wsaArchitecture            = "Intel64";
                // Player Capabilities
                UnityEditor.PlayerSettings.WSA.SetCapability(UnityEditor.PlayerSettings.WSACapability.InternetClient, true);
                UnityEditor.PlayerSettings.WSA.SetCapability(UnityEditor.PlayerSettings.WSACapability.InternetClientServer, true);
                UnityEditor.PlayerSettings.WSA.SetCapability(UnityEditor.PlayerSettings.WSACapability.PrivateNetworkClientServer, true);
                break;

            case MixedRealityProjectConfiguration.RunRemotelyOnWin32:
                remoting    = true;
                targetGroup = BuildTargetGroup.Standalone;
                EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
                break;

            default:
                return;
            }

            const string AppRemotingPlugin  = "Microsoft.MixedReality.OpenXR.Remoting.AppRemotingPlugin";
            Type         appRemotingFeature = typeof(AppRemoting).Assembly.GetType(AppRemotingPlugin);

            if (appRemotingFeature == null)
            {
                Debug.LogError($"Could not find {AppRemotingPlugin}. Has this class been removed or renamed?");
                return;
            }

            FeatureHelpers.RefreshFeatures(targetGroup);
            OpenXRFeature feature = OpenXRSettings.ActiveBuildTargetInstance.GetFeature(appRemotingFeature);

            if (feature == null)
            {
                Debug.LogError($"Could not load {AppRemotingPlugin} as an OpenXR feature. Has this class been removed or renamed?");
                return;
            }
            feature.enabled = remoting;

            XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(targetGroup);

            if (settings != null)
            {
                settings.InitManagerOnStart = !remoting;
            }
            Debug.Log($"Set up complete for {selectedMRConfiguration}");
        }
Exemplo n.º 2
0
        private void OnGUI()
        {
            m_selectedMRConfiguration   = MixedRealityProjectConfiguration.None;
            EditorGUIUtility.labelWidth = Default_Label_Width;
            GUIStyle titleStyle = new GUIStyle(EditorStyles.largeLabel)
            {
                fontStyle = FontStyle.Bold
            };
            GUIStyle contentStyle = new GUIStyle(EditorStyles.label)
            {
                fontStyle = FontStyle.Bold
            };

            // Welcome Title and Introduction
            GUILayout.Space(10);
            GUILayout.Box("Welcome to the Mixed Reality OpenXR Samples!", titleStyle, GUILayout.Width(Default_Label_Width));
            GUILayout.Space(10);
            GUILayout.Box("Change this project's settings for your Mixed Reality scenario:", contentStyle, GUILayout.Width(Default_Label_Width));
            GUILayout.Space(20);

            // Run Natively on PC VR
            GUI.Box(new Rect(5, 70, Default_Label_Width, 70), "To configure the project for running a Win32 application on PC with VR headset attached:");
            GUILayout.Space(30);
            if (GUILayout.Button("Win32 app running on PC VR", GUILayout.Width(Default_Label_Width)))
            {
                m_selectedMRConfiguration = MixedRealityProjectConfiguration.RunNativelyOnPCVR;
            }
            GUILayout.Space(20);

            // Run Natively on HL2
            GUI.Box(new Rect(5, 160, Default_Label_Width, 60), "To configure the project for running a UWP application HoloLens 2:");
            GUILayout.Space(40);
            if (GUILayout.Button("UWP app running on HoloLens 2", GUILayout.Width(Default_Label_Width)))
            {
                m_selectedMRConfiguration = MixedRealityProjectConfiguration.RunNativelyOnHL2;
            }
            GUILayout.Space(20);

            // Run Remotely on UWP
            GUI.Box(new Rect(5, 240, Default_Label_Width, 70), "To configure the project for building a Holographic remoting UWP application on PC/VM and running it on HoloLens 2:");
            GUILayout.Space(50);
            if (GUILayout.Button("Holographic Remoting remote UWP app", GUILayout.Width(Default_Label_Width)))
            {
                m_selectedMRConfiguration = MixedRealityProjectConfiguration.RunRemotelyOnUWP;
            }
            GUILayout.Space(20);

            // Run Remotely on Win32
            GUI.Box(new Rect(5, 330, Default_Label_Width, 70), "To configure the project for building a Holographic remoting Win32 application on PC/VM and running it on HoloLens 2:");
            GUILayout.Space(50);
            if (GUILayout.Button("Holographic Remoting remote Win32 app", GUILayout.Width(Default_Label_Width)))
            {
                m_selectedMRConfiguration = MixedRealityProjectConfiguration.RunRemotelyOnWin32;
            }
            GUILayout.Space(20);

            // Disable Popup option
            m_disablePopup = GUILayout.Toggle(UserSettings.DisablePopup, "Don't show this popup anymore");
            if (UserSettings.DisablePopup != m_disablePopup)
            {
                UserSettings.DisablePopup = m_disablePopup;
                SaveSettings();
            }

            ApplySelectedConfiguration(m_selectedMRConfiguration);
        }