protected virtual void OnValidate()
 {
     if (RenderPipelineManager.s_CurrentPipelineAsset == this)
     {
         RenderPipelineManager.CleanupRenderPipeline();
         RenderPipelineManager.PrepareRenderPipeline(this);
     }
 }
Esempio n. 2
0
 private static bool IsUsingCustomRenderPipeline()
 {
     if (RenderPipelineManager.get_currentPipeline() == null)
     {
         return(Object.op_Inequality((Object)GraphicsSettings.get_renderPipelineAsset(), (Object)null));
     }
     return(true);
 }
        public override void OnInspectorGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Changes made in play mode will not be saved.", MessageType.Warning, true);
            }

            m_QualitySettings.Update();

            var settings      = GetQualitySettings();
            var defaults      = GetDefaultQualityForPlatforms();
            var selectedLevel = QualitySettings.GetQualityLevel();

            EditorGUI.BeginChangeCheck();
            selectedLevel = DoQualityLevelSelection(selectedLevel, settings, defaults);
            if (EditorGUI.EndChangeCheck())
            {
                QualitySettings.SetQualityLevel(selectedLevel);
            }

            SetQualitySettings(settings);
            HandleAddRemoveQualitySetting(ref selectedLevel, defaults);
            SetDefaultQualityForPlatforms(defaults);
            GUILayout.Space(10.0f);
            DrawHorizontalDivider();
            GUILayout.Space(10.0f);

            var currentSettings                         = m_QualitySettingsProperty.GetArrayElementAtIndex(selectedLevel);
            var nameProperty                            = currentSettings.FindPropertyRelative("name");
            var pixelLightCountProperty                 = currentSettings.FindPropertyRelative("pixelLightCount");
            var shadowsProperty                         = currentSettings.FindPropertyRelative("shadows");
            var shadowResolutionProperty                = currentSettings.FindPropertyRelative("shadowResolution");
            var shadowProjectionProperty                = currentSettings.FindPropertyRelative("shadowProjection");
            var shadowCascadesProperty                  = currentSettings.FindPropertyRelative("shadowCascades");
            var shadowDistanceProperty                  = currentSettings.FindPropertyRelative("shadowDistance");
            var shadowNearPlaneOffsetProperty           = currentSettings.FindPropertyRelative("shadowNearPlaneOffset");
            var shadowCascade2SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade2Split");
            var shadowCascade4SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade4Split");
            var shadowMaskUsageProperty                 = currentSettings.FindPropertyRelative("shadowmaskMode");
            var skinWeightsProperty                     = currentSettings.FindPropertyRelative("skinWeights");
            var textureQualityProperty                  = currentSettings.FindPropertyRelative("textureQuality");
            var anisotropicTexturesProperty             = currentSettings.FindPropertyRelative("anisotropicTextures");
            var antiAliasingProperty                    = currentSettings.FindPropertyRelative("antiAliasing");
            var softParticlesProperty                   = currentSettings.FindPropertyRelative("softParticles");
            var realtimeReflectionProbes                = currentSettings.FindPropertyRelative("realtimeReflectionProbes");
            var billboardsFaceCameraPosition            = currentSettings.FindPropertyRelative("billboardsFaceCameraPosition");
            var vSyncCountProperty                      = currentSettings.FindPropertyRelative("vSyncCount");
            var lodBiasProperty                         = currentSettings.FindPropertyRelative("lodBias");
            var maximumLODLevelProperty                 = currentSettings.FindPropertyRelative("maximumLODLevel");
            var particleRaycastBudgetProperty           = currentSettings.FindPropertyRelative("particleRaycastBudget");
            var asyncUploadTimeSliceProperty            = currentSettings.FindPropertyRelative("asyncUploadTimeSlice");
            var asyncUploadBufferSizeProperty           = currentSettings.FindPropertyRelative("asyncUploadBufferSize");
            var asyncUploadPersistentBufferProperty     = currentSettings.FindPropertyRelative("asyncUploadPersistentBuffer");
            var resolutionScalingFixedDPIFactorProperty = currentSettings.FindPropertyRelative("resolutionScalingFixedDPIFactor");

            bool usingSRP = GraphicsSettings.renderPipelineAsset != null;

            if (string.IsNullOrEmpty(nameProperty.stringValue))
            {
                nameProperty.stringValue = "Level " + selectedLevel;
            }

            EditorGUILayout.PropertyField(nameProperty);

            if (usingSRP)
            {
                EditorGUILayout.HelpBox("A Scriptable Render Pipeline is in use, some settings will not be used and are hidden", MessageType.Info);
            }

            GUILayout.Space(10);

            GUILayout.Label(EditorGUIUtility.TempContent("Rendering"), EditorStyles.boldLabel);
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(pixelLightCountProperty);
            }

            // still valid with SRP
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(textureQualityProperty);
            if (EditorGUI.EndChangeCheck() && usingSRP)
            {
                RenderPipelineManager.CleanupRenderPipeline();
            }

            EditorGUILayout.PropertyField(anisotropicTexturesProperty);

            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(antiAliasingProperty);
                EditorGUILayout.PropertyField(softParticlesProperty);
                if (softParticlesProperty.boolValue)
                {
                    SoftParticlesHintGUI();
                }
            }

            EditorGUILayout.PropertyField(realtimeReflectionProbes);
            EditorGUILayout.PropertyField(billboardsFaceCameraPosition, Content.kBillboardsFaceCameraPos);
            EditorGUILayout.PropertyField(resolutionScalingFixedDPIFactorProperty);

            var streamingMipmapsActiveProperty = currentSettings.FindPropertyRelative("streamingMipmapsActive");

            EditorGUILayout.PropertyField(streamingMipmapsActiveProperty, Content.kStreamingMipmapsActive);
            if (streamingMipmapsActiveProperty.boolValue)
            {
                EditorGUI.indentLevel++;
                var streamingMipmapsAddAllCameras = currentSettings.FindPropertyRelative("streamingMipmapsAddAllCameras");
                EditorGUILayout.PropertyField(streamingMipmapsAddAllCameras, Content.kStreamingMipmapsAddAllCameras);
                var streamingMipmapsBudgetProperty = currentSettings.FindPropertyRelative("streamingMipmapsMemoryBudget");
                EditorGUILayout.PropertyField(streamingMipmapsBudgetProperty, Content.kStreamingMipmapsMemoryBudget);
                var streamingMipmapsRenderersPerFrameProperty = currentSettings.FindPropertyRelative("streamingMipmapsRenderersPerFrame");
                EditorGUILayout.PropertyField(streamingMipmapsRenderersPerFrameProperty, Content.kStreamingMipmapsRenderersPerFrame);
                var streamingMipmapsMaxLevelReductionProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxLevelReduction");
                EditorGUILayout.PropertyField(streamingMipmapsMaxLevelReductionProperty, Content.kStreamingMipmapsMaxLevelReduction);
                var streamingMipmapsMaxFileIORequestsProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxFileIORequests");
                EditorGUILayout.PropertyField(streamingMipmapsMaxFileIORequestsProperty, Content.kStreamingMipmapsMaxFileIORequests);
                EditorGUI.indentLevel--;
            }


            GUILayout.Space(10);

            GUILayout.Label(EditorGUIUtility.TempContent("Shadows"), EditorStyles.boldLabel);
            if (SupportedRenderingFeatures.IsMixedLightingModeSupported(MixedLightingMode.Shadowmask))
            {
                EditorGUILayout.PropertyField(shadowMaskUsageProperty);
            }

            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(shadowsProperty);
                EditorGUILayout.PropertyField(shadowResolutionProperty);
                EditorGUILayout.PropertyField(shadowProjectionProperty);
                EditorGUILayout.PropertyField(shadowDistanceProperty);
                EditorGUILayout.PropertyField(shadowNearPlaneOffsetProperty);
                EditorGUILayout.PropertyField(shadowCascadesProperty);

                if (shadowCascadesProperty.intValue == 2)
                {
                    DrawCascadeSplitGUI <float>(ref shadowCascade2SplitProperty);
                }
                else if (shadowCascadesProperty.intValue == 4)
                {
                    DrawCascadeSplitGUI <Vector3>(ref shadowCascade4SplitProperty);
                }
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Other"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(skinWeightsProperty);
            EditorGUILayout.PropertyField(vSyncCountProperty, Content.kVSyncCountLabel);
            EditorGUILayout.PropertyField(lodBiasProperty, Content.kLODBiasLabel);
            EditorGUILayout.PropertyField(maximumLODLevelProperty);
            EditorGUILayout.PropertyField(particleRaycastBudgetProperty);
            EditorGUILayout.PropertyField(asyncUploadTimeSliceProperty);
            EditorGUILayout.PropertyField(asyncUploadBufferSizeProperty);
            EditorGUILayout.PropertyField(asyncUploadPersistentBufferProperty);

            asyncUploadTimeSliceProperty.intValue  = Mathf.Clamp(asyncUploadTimeSliceProperty.intValue, kMinAsyncUploadTimeSlice, kMaxAsyncUploadTimeSlice);
            asyncUploadBufferSizeProperty.intValue = Mathf.Clamp(asyncUploadBufferSizeProperty.intValue, kMinAsyncRingBufferSize, kMaxAsyncRingBufferSize);

            if (m_Dragging != null && m_Dragging.m_Position != m_Dragging.m_StartPosition)
            {
                m_QualitySettingsProperty.MoveArrayElement(m_Dragging.m_StartPosition, m_Dragging.m_Position);
                m_Dragging.m_StartPosition = m_Dragging.m_Position;
                selectedLevel = m_Dragging.m_Position;

                m_QualitySettings.ApplyModifiedProperties();
                QualitySettings.SetQualityLevel(Mathf.Clamp(selectedLevel, 0, m_QualitySettingsProperty.arraySize - 1));
            }

            m_QualitySettings.ApplyModifiedProperties();
        }
 protected virtual void OnDisable()
 {
     RenderPipelineManager.CleanupRenderPipeline();
 }
 protected virtual void OnValidate()
 {
     RenderPipelineManager.CleanupRenderPipeline();
 }
        public override void OnInspectorGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Changes made in play mode will not be saved.", MessageType.Warning, true);
            }

            m_QualitySettings.Update();

            var settings      = GetQualitySettings();
            var defaults      = GetDefaultQualityForPlatforms();
            var selectedLevel = QualitySettings.GetQualityLevel();

            if (selectedLevel >= m_QualitySettingsProperty.arraySize)
            {
                selectedLevel = m_QualitySettingsProperty.arraySize - 1;
            }

            EditorGUI.BeginChangeCheck();
            selectedLevel = DoQualityLevelSelection(selectedLevel, settings, defaults);
            if (EditorGUI.EndChangeCheck())
            {
                QualitySettings.SetQualityLevel(selectedLevel);
            }

            SetQualitySettings(settings);
            HandleAddRemoveQualitySetting(ref selectedLevel, defaults);
            SetDefaultQualityForPlatforms(defaults);
            GUILayout.Space(10.0f);
            DrawHorizontalDivider();
            GUILayout.Space(10.0f);

            var currentSettings                         = m_QualitySettingsProperty.GetArrayElementAtIndex(selectedLevel);
            var nameProperty                            = currentSettings.FindPropertyRelative("name");
            var pixelLightCountProperty                 = currentSettings.FindPropertyRelative("pixelLightCount");
            var shadowsProperty                         = currentSettings.FindPropertyRelative("shadows");
            var shadowResolutionProperty                = currentSettings.FindPropertyRelative("shadowResolution");
            var shadowProjectionProperty                = currentSettings.FindPropertyRelative("shadowProjection");
            var shadowCascadesProperty                  = currentSettings.FindPropertyRelative("shadowCascades");
            var shadowDistanceProperty                  = currentSettings.FindPropertyRelative("shadowDistance");
            var shadowNearPlaneOffsetProperty           = currentSettings.FindPropertyRelative("shadowNearPlaneOffset");
            var shadowCascade2SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade2Split");
            var shadowCascade4SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade4Split");
            var shadowMaskUsageProperty                 = currentSettings.FindPropertyRelative("shadowmaskMode");
            var skinWeightsProperty                     = currentSettings.FindPropertyRelative("skinWeights");
            var textureQualityProperty                  = currentSettings.FindPropertyRelative("textureQuality");
            var anisotropicTexturesProperty             = currentSettings.FindPropertyRelative("anisotropicTextures");
            var antiAliasingProperty                    = currentSettings.FindPropertyRelative("antiAliasing");
            var softParticlesProperty                   = currentSettings.FindPropertyRelative("softParticles");
            var realtimeReflectionProbes                = currentSettings.FindPropertyRelative("realtimeReflectionProbes");
            var billboardsFaceCameraPosition            = currentSettings.FindPropertyRelative("billboardsFaceCameraPosition");
            var vSyncCountProperty                      = currentSettings.FindPropertyRelative("vSyncCount");
            var lodBiasProperty                         = currentSettings.FindPropertyRelative("lodBias");
            var maximumLODLevelProperty                 = currentSettings.FindPropertyRelative("maximumLODLevel");
            var enableLODCrossFadeProperty              = currentSettings.FindPropertyRelative("enableLODCrossFade");
            var particleRaycastBudgetProperty           = currentSettings.FindPropertyRelative("particleRaycastBudget");
            var asyncUploadTimeSliceProperty            = currentSettings.FindPropertyRelative("asyncUploadTimeSlice");
            var asyncUploadBufferSizeProperty           = currentSettings.FindPropertyRelative("asyncUploadBufferSize");
            var asyncUploadPersistentBufferProperty     = currentSettings.FindPropertyRelative("asyncUploadPersistentBuffer");
            var resolutionScalingFixedDPIFactorProperty = currentSettings.FindPropertyRelative("resolutionScalingFixedDPIFactor");

            var customRenderPipeline = currentSettings.FindPropertyRelative("customRenderPipeline");

            bool usingSRP = GraphicsSettings.currentRenderPipeline != null;

            if (string.IsNullOrEmpty(nameProperty.stringValue))
            {
                nameProperty.stringValue = "Level " + selectedLevel;
            }

            GUILayout.Label(EditorGUIUtility.TempContent("Current Active Quality Level"), EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(nameProperty);

            if (usingSRP)
            {
                EditorGUILayout.HelpBox("A Scriptable Render Pipeline is in use, some settings will not be used and are hidden", MessageType.Info);
            }
            GUILayout.Space(10);

            GUILayout.Label(EditorGUIUtility.TempContent("Rendering"), EditorStyles.boldLabel);

            EditorGUI.RenderPipelineAssetField(Content.kRenderPipelineObject, m_QualitySettings, customRenderPipeline);
            if (!usingSRP && customRenderPipeline.objectReferenceValue != null)
            {
                EditorGUILayout.HelpBox("Missing a Scriptable Render Pipeline in Graphics: \"Scriptable Render Pipeline Settings\" to use Scriptable Render Pipeline from Quality: \"Custom Render Pipeline\".", MessageType.Warning);
            }

            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(pixelLightCountProperty);
            }

            // still valid with SRP
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(antiAliasingProperty);
            }

            if (!SupportedRenderingFeatures.active.overridesRealtimeReflectionProbes)
            {
                EditorGUILayout.PropertyField(realtimeReflectionProbes);
            }
            EditorGUILayout.PropertyField(resolutionScalingFixedDPIFactorProperty);

            EditorGUILayout.PropertyField(vSyncCountProperty, Content.kVSyncCountLabel);

            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android ||
                EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS ||
                EditorUserBuildSettings.activeBuildTarget == BuildTarget.tvOS)
            {
                if (vSyncCountProperty.intValue > 0)
                {
                    EditorGUILayout.HelpBox(EditorGUIUtility.TrTextContent($"VSync Count '{vSyncCountProperty.enumLocalizedDisplayNames[vSyncCountProperty.enumValueIndex]}' is ignored on Android, iOS and tvOS.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)));
                }
            }

            bool shadowMaskSupported = SupportedRenderingFeatures.IsMixedLightingModeSupported(MixedLightingMode.Shadowmask);
            bool showShadowMaskUsage = shadowMaskSupported && !SupportedRenderingFeatures.active.overridesShadowmask;

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Textures"), EditorStyles.boldLabel);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(textureQualityProperty);
            if (EditorGUI.EndChangeCheck() && usingSRP)
            {
                RenderPipelineManager.CleanupRenderPipeline();
            }
            if (QualitySettings.IsTextureResReducedOnAnyPlatform())
            {
                MipStrippingHintGUI();
            }
            EditorGUILayout.PropertyField(anisotropicTexturesProperty);

            var streamingMipmapsActiveProperty = currentSettings.FindPropertyRelative("streamingMipmapsActive");

            EditorGUILayout.PropertyField(streamingMipmapsActiveProperty, Content.kStreamingMipmapsActive);
            if (streamingMipmapsActiveProperty.boolValue)
            {
                EditorGUI.indentLevel++;
                var streamingMipmapsAddAllCameras = currentSettings.FindPropertyRelative("streamingMipmapsAddAllCameras");
                EditorGUILayout.PropertyField(streamingMipmapsAddAllCameras, Content.kStreamingMipmapsAddAllCameras);
                var streamingMipmapsBudgetProperty = currentSettings.FindPropertyRelative("streamingMipmapsMemoryBudget");
                EditorGUILayout.PropertyField(streamingMipmapsBudgetProperty, Content.kStreamingMipmapsMemoryBudget);
                var streamingMipmapsRenderersPerFrameProperty = currentSettings.FindPropertyRelative("streamingMipmapsRenderersPerFrame");
                EditorGUILayout.PropertyField(streamingMipmapsRenderersPerFrameProperty, Content.kStreamingMipmapsRenderersPerFrame);
                var streamingMipmapsMaxLevelReductionProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxLevelReduction");
                EditorGUILayout.PropertyField(streamingMipmapsMaxLevelReductionProperty, Content.kStreamingMipmapsMaxLevelReduction);
                var streamingMipmapsMaxFileIORequestsProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxFileIORequests");
                EditorGUILayout.PropertyField(streamingMipmapsMaxFileIORequestsProperty, Content.kStreamingMipmapsMaxFileIORequests);
                EditorGUI.indentLevel--;
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Particles"), EditorStyles.boldLabel);
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(softParticlesProperty);
                if (softParticlesProperty.boolValue)
                {
                    SoftParticlesHintGUI();
                }
            }
            EditorGUILayout.PropertyField(particleRaycastBudgetProperty);

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Terrain"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(billboardsFaceCameraPosition, Content.kBillboardsFaceCameraPos);

            if (!usingSRP || showShadowMaskUsage)
            {
                GUILayout.Space(10);

                GUILayout.Label(EditorGUIUtility.TempContent("Shadows"), EditorStyles.boldLabel);

                if (showShadowMaskUsage)
                {
                    EditorGUILayout.PropertyField(shadowMaskUsageProperty);
                }

                if (!usingSRP)
                {
                    EditorGUILayout.PropertyField(shadowsProperty);
                    EditorGUILayout.PropertyField(shadowResolutionProperty);
                    EditorGUILayout.PropertyField(shadowProjectionProperty);
                    EditorGUILayout.PropertyField(shadowDistanceProperty);
                    EditorGUILayout.PropertyField(shadowNearPlaneOffsetProperty);
                    EditorGUILayout.PropertyField(shadowCascadesProperty);

                    if (shadowCascadesProperty.intValue == 2)
                    {
                        DrawCascadeSplitGUI <float>(ref shadowCascade2SplitProperty);
                    }
                    else if (shadowCascadesProperty.intValue == 4)
                    {
                        DrawCascadeSplitGUI <Vector3>(ref shadowCascade4SplitProperty);
                    }
                }
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Async Asset Upload"), EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(asyncUploadTimeSliceProperty, Content.kAsyncUploadTimeSlice);
            EditorGUILayout.PropertyField(asyncUploadBufferSizeProperty, Content.kAsyncUploadBufferSize);
            EditorGUILayout.PropertyField(asyncUploadPersistentBufferProperty, Content.kAsyncUploadPersistentBuffer);

            asyncUploadTimeSliceProperty.intValue  = Mathf.Clamp(asyncUploadTimeSliceProperty.intValue, kMinAsyncUploadTimeSlice, kMaxAsyncUploadTimeSlice);
            asyncUploadBufferSizeProperty.intValue = Mathf.Clamp(asyncUploadBufferSizeProperty.intValue, kMinAsyncRingBufferSize, kMaxAsyncRingBufferSize);

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Level of Detail"), EditorStyles.boldLabel);

            if (!SupportedRenderingFeatures.active.overridesLODBias)
            {
                EditorGUILayout.PropertyField(lodBiasProperty, Content.kLODBiasLabel);
            }
            if (!SupportedRenderingFeatures.active.overridesMaximumLODLevel)
            {
                EditorGUILayout.PropertyField(maximumLODLevelProperty, Content.kMaximumLODLevelLabel);
            }
            if (!SupportedRenderingFeatures.active.overridesEnableLODCrossFade)
            {
                EditorGUILayout.PropertyField(enableLODCrossFadeProperty, Content.kEnableLODCrossFadeLabel);
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Meshes"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(skinWeightsProperty);

            if (m_Dragging != null && m_Dragging.m_Position != m_Dragging.m_StartPosition)
            {
                m_QualitySettingsProperty.MoveArrayElement(m_Dragging.m_StartPosition, m_Dragging.m_Position);
                m_Dragging.m_StartPosition = m_Dragging.m_Position;
                selectedLevel = m_Dragging.m_Position;

                m_QualitySettings.ApplyModifiedProperties();
                QualitySettings.SetQualityLevel(Mathf.Clamp(selectedLevel, 0, m_QualitySettingsProperty.arraySize - 1));
            }

            m_QualitySettings.ApplyModifiedProperties();
        }