Esempio n. 1
0
        public void SplashSectionGUI(BuildPlatform platform, BuildTargetGroup targetGroup, ISettingEditorExtension settingsExtension, int sectionIndex = 2)
        {
            if (m_Owner.BeginSettingsBox(sectionIndex, k_Texts.title))
            {
                if (m_Owner.m_VRSettings.TargetGroupSupportsVirtualReality(targetGroup))
                {
                    ObjectReferencePropertyField <Texture2D>(m_VirtualRealitySplashScreen, k_Texts.vrSplashScreen);
                }

                if (TargetSupportsOptionalBuiltinSplashScreen(targetGroup, settingsExtension))
                {
                    BuiltinCustomSplashScreenGUI();
                }

                if (settingsExtension != null)
                {
                    settingsExtension.SplashSectionGUI();
                }

                if (m_ShowUnitySplashScreen.boolValue)
                {
                    m_Owner.ShowSharedNote();
                }
            }
            m_Owner.EndSettingsBox();
        }
        public void SplashSectionGUI(BuildPlatform platform, ISettingEditorExtension settingsExtension, int sectionIndex = 2)
        {
            if (m_Owner.BeginSettingsBox(sectionIndex, k_Texts.title))
            {
                if (platform.namedBuildTarget == NamedBuildTarget.Server)
                {
                    PlayerSettingsEditor.ShowNoSettings();
                    EditorGUILayout.Space();
                }
                else
                {
                    ObjectReferencePropertyField <Texture2D>(m_VirtualRealitySplashScreen, k_Texts.vrSplashScreen);

                    if (TargetSupportsOptionalBuiltinSplashScreen(platform.namedBuildTarget.ToBuildTargetGroup(), settingsExtension))
                    {
                        BuiltinCustomSplashScreenGUI(platform.namedBuildTarget.ToBuildTargetGroup(), settingsExtension);
                    }

                    if (settingsExtension != null)
                    {
                        settingsExtension.SplashSectionGUI();
                    }

                    if (m_ShowUnitySplashScreen.boolValue)
                    {
                        m_Owner.ShowSharedNote();
                    }
                }
            }
            m_Owner.EndSettingsBox();
        }
Esempio n. 3
0
        internal void XRSectionGUI(BuildTargetGroup targetGroup, int sectionIndex)
        {
            GUISectionIndex = sectionIndex;

            if (!TargetGroupSupportsVirtualReality(targetGroup) && !TargetGroupSupportsAugmentedReality(targetGroup))
            {
                return;
            }

            if (m_VRDeviceActiveUI.ContainsKey(targetGroup) && VREditor.IsDeviceListDirty(targetGroup))
            {
                VREditor.ClearDeviceListDirty(targetGroup);
                m_VRDeviceActiveUI[targetGroup].list = VREditor.GetVREnabledDevicesOnTargetGroup(targetGroup);
            }

            // Check to see if any devices require an install and need their GUI hidden
            CheckDevicesRequireInstall(targetGroup);

            if (m_Settings.BeginSettingsBox(sectionIndex, Styles.xrSettingsTitle))
            {
                if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.HelpBox("Changing XR Settings is not allowed in play mode.", MessageType.Info);
                }

                using (new EditorGUI.DisabledScope(EditorApplication.isPlaying)) // switching VR flags in play mode is not supported
                {
                    DevicesGUI(targetGroup);

                    ErrorOnVRDeviceIncompatibility(targetGroup);

                    SinglePassStereoGUI(targetGroup, m_StereoRenderingPath);

                    TangoGUI(targetGroup);

                    VuforiaGUI(targetGroup);

                    RemotingWSAHolographicGUI(targetGroup);

                    Stereo360CaptureGUI(targetGroup);

                    ErrorOnARDeviceIncompatibility(targetGroup);
                }

                InstallGUI(targetGroup);
            }
            m_Settings.EndSettingsBox();
        }
        public void SplashSectionGUI(BuildPlatform platform, BuildTargetGroup targetGroup, ISettingEditorExtension settingsExtension, int sectionIndex = 2)
        {
            if (m_Owner.BeginSettingsBox(sectionIndex, k_Texts.title))
            {
                if (targetGroup == BuildTargetGroup.Standalone)
                {
                    ObjectReferencePropertyField <Texture2D>(m_ResolutionDialogBanner, k_Texts.configDialogBanner);
                    if (m_ResolutionDialogBanner.objectReferenceValue != null)
                    {
                        EditorGUILayout.HelpBox(k_Texts.configDialogBannerDeprecationWarning.text, MessageType.Warning, true);
                    }

                    EditorGUILayout.Space();
                }

                if (m_Owner.m_VRSettings.TargetGroupSupportsVirtualReality(targetGroup))
                {
                    ObjectReferencePropertyField <Texture2D>(m_VirtualRealitySplashScreen, k_Texts.vrSplashScreen);
                }

                if (TargetSupportsOptionalBuiltinSplashScreen(targetGroup, settingsExtension))
                {
                    BuiltinCustomSplashScreenGUI();
                }

                if (settingsExtension != null)
                {
                    settingsExtension.SplashSectionGUI();
                }

                if (m_ShowUnitySplashScreen.boolValue)
                {
                    m_Owner.ShowSharedNote();
                }
            }
            m_Owner.EndSettingsBox();
        }
        internal void XRSectionGUI(BuildTargetGroup targetGroup, int sectionIndex)
        {
            GUISectionIndex = sectionIndex;

            if (!TargetGroupSupportsVirtualReality(targetGroup) && !TargetGroupSupportsAugmentedReality(targetGroup))
            {
                return;
            }

            if (m_VRDeviceActiveUI.ContainsKey(targetGroup) && VREditor.IsDeviceListDirty(targetGroup))
            {
                VREditor.ClearDeviceListDirty(targetGroup);
                if (m_VRDeviceActiveUI.ContainsKey(targetGroup))
                {
                    m_VRDeviceActiveUI[targetGroup].list = VREditor.GetVREnabledDevicesOnTargetGroup(targetGroup);
                }
            }

            // Check to see if any devices require an install and need their GUI hidden
            CheckDevicesRequireInstall(targetGroup);

            if (m_Settings.BeginSettingsBox(sectionIndex, Styles.xrSettingsTitle))
            {
                if (EditorApplication.isPlaying)
                {
                    EditorGUILayout.HelpBox("Changing XR Settings is not allowed in play mode.", MessageType.Info);
                }

                using (new EditorGUI.DisabledScope(EditorApplication.isPlaying)) // switching VR flags in play mode is not supported
                {
                    bool shouldVRDeviceSettingsBeDisabled = XRProjectSettings.GetBool(XRProjectSettings.KnownSettings.k_VRDeviceDisabled, false);;
                    using (new EditorGUI.DisabledGroupScope(shouldVRDeviceSettingsBeDisabled))
                    {
                        if (shouldVRDeviceSettingsBeDisabled)
                        {
                            EditorGUILayout.HelpBox("Legacy XR is currently disabled. Unity has detected that you have one or more XR SDK Provider packages installed. Legacy XR is incompatible with XR SDK. Remove all XR SDK Pacakges from your project to re-enable legacy XR", MessageType.Warning);

                            if (!XRProjectSettings.GetBool(XRProjectSettings.KnownSettings.k_VRDeviceDidAlertUser))
                            {
                                EditorUtility.DisplayDialog("Legacy XR Disabled", "Unity has detected that you have one or more XR SDK Provider packages installed. Legacy XR is incompatible with XR SDK. Remove all XR SDK Pacakges from your project to re-enable legacy XR", "Ok");
                                XRProjectSettings.SetBool(XRProjectSettings.KnownSettings.k_VRDeviceDidAlertUser, true);
                            }
                        }
                        DevicesGUI(targetGroup);

                        ErrorOnVRDeviceIncompatibility(targetGroup);
                    }

                    SinglePassStereoGUI(targetGroup, m_StereoRenderingPath);

                    TangoGUI(targetGroup);

                    VuforiaGUI(targetGroup);

                    RemotingWSAHolographicGUI(targetGroup);

                    Stereo360CaptureGUI(targetGroup);

                    ErrorOnARDeviceIncompatibility(targetGroup);

                    WarnOnGraphicsAPIIncompatibility(targetGroup);
                }

                InstallGUI(targetGroup);
            }
            m_Settings.EndSettingsBox();
        }
        public void IconSectionGUI(NamedBuildTarget namedBuildTarget, ISettingEditorExtension settingsExtension, int platformID, int sectionIndex)
        {
            m_SelectedPlatform = platformID;
            if (!m_Owner.BeginSettingsBox(sectionIndex, SettingsContent.iconTitle))
            {
                m_Owner.EndSettingsBox();
                return;
            }

            var platformUsesStandardIcons = true;

            if (settingsExtension != null)
            {
                platformUsesStandardIcons = settingsExtension.UsesStandardIcons();
            }

            if (platformUsesStandardIcons)
            {
                var selectedDefault = (m_SelectedPlatform < 0);
                // Set default platform variables
                BuildPlatform platform = null;
                namedBuildTarget = NamedBuildTarget.Standalone;
                var platformName = "";

                // Override if a platform is selected
                if (!selectedDefault)
                {
                    platform         = m_ValidPlatforms[m_SelectedPlatform];
                    namedBuildTarget = platform.namedBuildTarget;
                    platformName     = platform.name;
                }

                if (namedBuildTarget == NamedBuildTarget.WebGL || namedBuildTarget == NamedBuildTarget.Server)
                {
                    PlayerSettingsEditor.ShowNoSettings();
                    EditorGUILayout.Space();
                }
                else if (namedBuildTarget != NamedBuildTarget.WindowsStoreApps) // UWP does this in its editor extension
                {
                    // Both default icon and Legacy icons are serialized to the same map
                    // That's why m_LegacyPlatformIcons can be excluded in two places (other place in CommonSettings())
                    using (var vertical = new EditorGUILayout.VerticalScope())
                        using (new EditorGUI.PropertyScope(vertical.rect, GUIContent.none, m_LegacyPlatformIcons))
                        {
                            // Get icons and icon sizes for selected platform (or default)
                            var icons   = PlayerSettings.GetPlatformIconsForTargetIcons(platformName, IconKind.Any, m_AllLegacyIcons);
                            var widths  = PlayerSettings.GetIconWidthsForPlatform(platformName, IconKind.Any);
                            var heights = PlayerSettings.GetIconHeightsForPlatform(platformName, IconKind.Any);
                            var kinds   = PlayerSettings.GetIconKindsForPlatform(platformName);

                            var overrideIcons = true;

                            if (!selectedDefault)
                            {
                                // If the list of icons for this platform is not empty (and has the correct size),
                                // consider the icon overridden for this platform
                                EditorGUI.BeginChangeCheck();
                                overrideIcons = (icons.Length == widths.Length);
                                overrideIcons = GUILayout.Toggle(overrideIcons, string.Format(L10n.Tr("Override for {0}"), platform.title.text));
                                EditorGUI.BeginDisabled(!overrideIcons);
                                var changed = EditorGUI.EndChangeCheck();
                                if (changed || (!overrideIcons && icons.Length > 0))
                                {
                                    // Set the list of icons to correct length if overridden, otherwise to an empty list
                                    if (overrideIcons)
                                    {
                                        icons = new Texture2D[widths.Length];
                                    }
                                    else
                                    {
                                        icons = new Texture2D[0];
                                    }

                                    if (changed)
                                    {
                                        SetLegacyPlatformIcons(platformName, icons, IconKind.Any, ref m_AllLegacyIcons);
                                    }
                                }
                            }

                            // Show the icons for this platform (or default)
                            EditorGUI.BeginChangeCheck();
                            for (int i = 0; i < widths.Length; i++)
                            {
                                var previewWidth  = Mathf.Min(kMaxPreviewSize, widths[i]);
                                var previewHeight = (int)((float)heights[i] * previewWidth / widths[i]); // take into account the aspect ratio

                                if (namedBuildTarget == NamedBuildTarget.iOS)
                                {
                                    // Spotlight icons begin with 120 but there are two in the list.
                                    // So check if the next one is 80.
                                    if (kinds[i] == IconKind.Spotlight && kinds[i - 1] != IconKind.Spotlight)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "Spotlight icons", EditorStyles.boldLabel);
                                    }

                                    if (kinds[i] == IconKind.Settings && kinds[i - 1] != IconKind.Settings)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "Settings icons", EditorStyles.boldLabel);
                                    }

                                    if (kinds[i] == IconKind.Notification && kinds[i - 1] != IconKind.Notification)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "Notification icons", EditorStyles.boldLabel);
                                    }

                                    if (kinds[i] == IconKind.Store && kinds[i - 1] != IconKind.Store)
                                    {
                                        var labelRect = GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 20);
                                        GUI.Label(new Rect(labelRect.x, labelRect.y, EditorGUIUtility.labelWidth, 20), "App Store icons", EditorStyles.boldLabel);
                                    }
                                }

                                var rect  = GUILayoutUtility.GetRect(kSlotSize, Mathf.Max(kSlotSize, previewHeight) + kIconSpacing);
                                var width = Mathf.Min(rect.width, EditorGUIUtility.labelWidth + 4 + kSlotSize + kIconSpacing + kMaxPreviewSize);

                                // Label
                                var label = widths[i] + "x" + heights[i];
                                GUI.Label(new Rect(rect.x, rect.y, width - kMaxPreviewSize - kSlotSize - 2 * kIconSpacing, 20), label);

                                // Texture slot
                                if (overrideIcons)
                                {
                                    var slotWidth  = kSlotSize;
                                    var slotHeight = (int)((float)heights[i] / widths[i] * kSlotSize); // take into account the aspect ratio
                                    icons[i] = (Texture2D)EditorGUI.ObjectField(
                                        new Rect(rect.x + width - kMaxPreviewSize - kSlotSize - kIconSpacing, rect.y, slotWidth, slotHeight),
                                        icons[i],
                                        typeof(Texture2D),
                                        false);
                                }

                                // Preview
                                var previewRect = new Rect(rect.x + width - kMaxPreviewSize, rect.y, previewWidth, previewHeight);
                                var closestIcon = PlayerSettings.GetPlatformIconForSizeForTargetIcons(platformName, widths[i], heights[i], kinds[i], m_AllLegacyIcons);
                                if (closestIcon != null)
                                {
                                    GUI.DrawTexture(previewRect, closestIcon);
                                }
                                else
                                {
                                    GUI.Box(previewRect, "");
                                }
                            }

                            // Save changes
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObjects(m_Owner.targets, SettingsContent.undoChangedIconString);
                                SetLegacyPlatformIcons(platformName, icons, IconKind.Any, ref m_AllLegacyIcons);
                            }

                            EditorGUI.EndDisabled();

                            if (namedBuildTarget == NamedBuildTarget.iOS || namedBuildTarget == NamedBuildTarget.tvOS)
                            {
                                EditorGUILayout.PropertyField(m_UIPrerenderedIcon, SettingsContent.UIPrerenderedIcon);
                                EditorGUILayout.Space();
                            }
                        }
                }
            }

            if (settingsExtension != null)
            {
                settingsExtension.IconSectionGUI();
            }

            m_Owner.EndSettingsBox();
        }