Exemplo n.º 1
0
        public bool PopulateNewSettingsInstance(ScriptableObject obj)
        {
            WindowsMRPackageSettings packageSettings = obj as WindowsMRPackageSettings;

            if (packageSettings != null)
            {
                var settings = packageSettings.GetSettingsForBuildTargetGroup(BuildTargetGroup.WSA);
                if (settings != null)
                {
#pragma warning disable 0618
                    switch (PlayerSettings.VRWindowsMixedReality.depthBufferFormat)
                    {
                    case PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat16Bit:
                        settings.DepthBufferFormat = WindowsMRSettings.DepthBufferOption.DepthBuffer16Bit;
                        break;

                    case PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat24Bit:
                        settings.DepthBufferFormat = WindowsMRSettings.DepthBufferOption.DepthBuffer24Bit;
                        break;
                    }

                    settings.UseSharedDepthBuffer = PlayerSettings.VRWindowsMixedReality.depthBufferSharingEnabled;
#pragma warning restore 0618
                    return(true);

#pragma warning restore 0618
                }
            }
            return(false);
        }
        private WindowsMRPackageSettings PackageSettingsForBuildTargetGroup(BuildTargetGroup buildTargetGroup)
        {
            if (!HasLoaderEnabledForTarget(buildTargetGroup))
            {
                return(null);
            }

            UnityEngine.Object settingsObj = null;
            EditorBuildSettings.TryGetConfigObject(BuildSettingsKey, out settingsObj);
            WindowsMRPackageSettings settings = settingsObj as WindowsMRPackageSettings;

            if (settings == null)
            {
                var assets = AssetDatabase.FindAssets("t:WindowsMRPackageSettings");
                if (assets.Length == 1)
                {
                    string path = AssetDatabase.GUIDToAssetPath(assets[0]);
                    settings = AssetDatabase.LoadAssetAtPath(path, typeof(WindowsMRPackageSettings)) as WindowsMRPackageSettings;
                    if (settings != null)
                    {
                        EditorBuildSettings.AddConfigObject(BuildSettingsKey, settings, true);
                    }
                }
            }

            return(settings);
        }
Exemplo n.º 3
0
        /// <summary>Will populate default settings on package initialization.</summary>
        /// <param name="obj">The scriptable object instance from the Asset Database that is an instance of WindowsMRPacakgeSettings</param>
        /// <returns>True if settings were populated, else false.</returns>
        /// <seealso cref="WindowsMRPackageSettings" />
        public bool PopulateSettingsOnInitialization(ScriptableObject obj)
        {
            WindowsMRPackageSettings packageSettings = obj as WindowsMRPackageSettings;

            if (packageSettings != null)
            {
                var settings = packageSettings.GetSettingsForBuildTargetGroup(BuildTargetGroup.WSA);
                if (settings != null)
                {
                    switch (PlayerSettings.VRWindowsMixedReality.depthBufferFormat)
                    {
                    case PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat16Bit:
                        settings.DepthBufferFormat = WindowsMRSettings.DepthBufferOption.DepthBuffer16Bit;
                        break;

                    case PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat24Bit:
                        settings.DepthBufferFormat = WindowsMRSettings.DepthBufferOption.DepthBuffer24Bit;
                        break;
                    }

                    settings.UseSharedDepthBuffer = PlayerSettings.VRWindowsMixedReality.depthBufferSharingEnabled;
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>Get a generic object reference for runtime settings for the build platform</summary>
        /// <param name="buildTargetGroup">The build platform we want to get settings for.</param>
        /// <returns>An object instance of the saved settings, or null if there are none.</returns>
        public override UnityEngine.Object SettingsForBuildTargetGroup(BuildTargetGroup buildTargetGroup)
        {
            WindowsMRPackageSettings settings = PackageSettingsForBuildTargetGroup(buildTargetGroup);

            if (settings != null)
            {
                WindowsMRSettings targetSettings = settings.GetSettingsForBuildTargetGroup(buildTargetGroup);
                return(targetSettings);
            }

            return(null);
        }
        /// <summary>Get the XR Plugin build settings for the specific build platform.</summary>
        /// <param name="buildTargetGroup">The build platform we want to get settings for.</param>
        /// <returns>An instance of WindowsMRBuildSettings, or null if there are none for the current build platform.</returns>
        public WindowsMRBuildSettings BuildSettingsForBuildTargetGroup(BuildTargetGroup buildTargetGroup)
        {
            WindowsMRPackageSettings settings = PackageSettingsForBuildTargetGroup(buildTargetGroup);

            if (settings != null)
            {
                WindowsMRBuildSettings targetSettings = settings.GetBuildSettingsForBuildTargetGroup(buildTargetGroup);
                return(targetSettings);
            }

            return(null);
        }
Exemplo n.º 6
0
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            WindowsMRPackageSettings settings = serializedObject.targetObject as WindowsMRPackageSettings;

            BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            if (buildTargetGroup == BuildTargetGroup.Standalone || buildTargetGroup == BuildTargetGroup.WSA)
            {
                serializedObject.Update();

                if (buildTargetGroup == BuildTargetGroup.WSA)
                {
                    m_ShowBuildSettings = EditorGUILayout.Foldout(m_ShowBuildSettings, s_ShowBuildSettingsLabel);
                    if (m_ShowBuildSettings)
                    {
                        var serializedSettingsObject = new SerializedObject(settings.GetBuildSettingsForBuildTargetGroup(buildTargetGroup));
                        serializedSettingsObject.Update();

                        SerializedProperty forcePrimaryWindowHologrpahic = serializedSettingsObject.FindProperty(k_ForcePrimaryWindowHolographic);

                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(forcePrimaryWindowHologrpahic, s_ForcePrimaryWindowHologrpahicLabel);
                        EditorGUI.indentLevel--;
                        serializedSettingsObject.ApplyModifiedProperties();
                    }
                }

                EditorGUILayout.Space();

                if (buildTargetGroup == BuildTargetGroup.WSA)
                {
                    m_ShowRuntimeSettings = EditorGUILayout.Foldout(m_ShowRuntimeSettings, s_ShowRuntimeSettingsLabel);
                }
                else
                {
                    m_ShowRuntimeSettings = true;
                }

                if (m_ShowRuntimeSettings)
                {
                    var serializedSettingsObject = new SerializedObject(settings.GetSettingsForBuildTargetGroup(buildTargetGroup));
                    serializedSettingsObject.Update();

                    SerializedProperty depthBufferFormat = serializedSettingsObject.FindProperty(k_DepthBufferFormat);
                    SerializedProperty sharedDepthBuffer = serializedSettingsObject.FindProperty(k_SharedDepthBuffer);

                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(depthBufferFormat, s_DepthBufferFormatLabel);
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(sharedDepthBuffer, s_SharedDepthBufferLabel);
                    EditorGUI.indentLevel--;
                    serializedSettingsObject.ApplyModifiedProperties();
                }
                serializedObject.ApplyModifiedProperties();
            }
            else
            {
                EditorGUILayout.HelpBox("Settings for this package are unsupported for this target platform.", MessageType.Info);
            }
            EditorGUILayout.EndBuildTargetSelectionGrouping();
        }
        /// <summary>
        /// GUI for WindowsMRSettingsEditor class.
        /// </summary>
        public override void OnInspectorGUI()
        {
            if (serializedObject == null || serializedObject.targetObject == null)
            {
                return;
            }

            WindowsMRPackageSettings settings = serializedObject.targetObject as WindowsMRPackageSettings;

            BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            if (buildTargetGroup == BuildTargetGroup.Standalone || buildTargetGroup == BuildTargetGroup.WSA)
            {
                var mgmtsettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);

                serializedObject.Update();

                m_ShowBuildSettings = EditorGUILayout.Foldout(m_ShowBuildSettings, s_ShowBuildSettingsLabel);
                if (m_ShowBuildSettings)
                {
                    var serializedSettingsObject = new SerializedObject(settings.GetBuildSettingsForBuildTargetGroup(buildTargetGroup));
                    serializedSettingsObject.Update();

                    SerializedProperty holographicRemoting           = serializedSettingsObject.FindProperty(k_HolographicRemoting);
                    SerializedProperty forcePrimaryWindowHolographic = serializedSettingsObject.FindProperty(k_ForcePrimaryWindowHolographic);
                    EditorGUI.indentLevel++;

                    if (buildTargetGroup == BuildTargetGroup.WSA)
                    {
                        EditorGUI.BeginDisabledGroup(holographicRemoting.boolValue);

                        if (holographicRemoting.boolValue && forcePrimaryWindowHolographic.boolValue)
                        {
                            forcePrimaryWindowHolographic.boolValue = false;
                            Debug.LogWarning("Holographic remoting has been enabled. This requires use of primary window to be disabled.");
                        }

                        EditorGUILayout.PropertyField(forcePrimaryWindowHolographic, s_forcePrimaryWindowHolographicLabel);
                        EditorGUI.EndDisabledGroup();
                        EditorGUILayout.Space();
                    }

                    EditorGUILayout.PropertyField(holographicRemoting, s_HolographicRemotingLabel);
                    EditorGUI.indentLevel--;


                    if (mgmtsettings != null)
                    {
                        if (holographicRemoting.boolValue == mgmtsettings.InitManagerOnStart)
                        {
                            mgmtsettings.InitManagerOnStart = !holographicRemoting.boolValue;
                            if (!mgmtsettings.InitManagerOnStart)
                            {
                                Debug.LogWarning("Holographic remoting has been enabled. This requires XR Plug-in Management Initialize on Startup to be disabled.");
                            }
                            else
                            {
                                Debug.LogWarning("Holographic remoting has been disabled. XR Plug-in Management Initialize on Startup has been re-enabled.");
                            }
                        }
                    }

                    serializedSettingsObject.ApplyModifiedProperties();
                }


                EditorGUILayout.Space();

                m_ShowRuntimeSettings = EditorGUILayout.Foldout(m_ShowRuntimeSettings, s_ShowRuntimeSettingsLabel);

                if (m_ShowRuntimeSettings)
                {
                    var serializedSettingsObject = new SerializedObject(settings.GetSettingsForBuildTargetGroup(buildTargetGroup));
                    serializedSettingsObject.Update();

                    SerializedProperty depthBufferFormat = serializedSettingsObject.FindProperty(k_DepthBufferFormat);
                    SerializedProperty sharedDepthBuffer = serializedSettingsObject.FindProperty(k_SharedDepthBuffer);

                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(depthBufferFormat, s_DepthBufferFormatLabel);
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(sharedDepthBuffer, s_SharedDepthBufferLabel);
                    EditorGUI.indentLevel--;
                    serializedSettingsObject.ApplyModifiedProperties();
                }
                serializedObject.ApplyModifiedProperties();
            }
            else
            {
                EditorGUILayout.HelpBox("Settings for this package are unsupported for this target platform.", MessageType.Info);
            }
            EditorGUILayout.EndBuildTargetSelectionGrouping();
        }