public override void OnInspectorGUI()
        {
            PropertyField(m_Type);

            if (m_Type.value.intValue == (int)FilmGrainLookup.Custom)
            {
                PropertyField(m_Texture);

                var texture = (target as FilmGrain).texture.value;

                if (texture != null)
                {
                    var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter;

                    // Fails when using an internal texture as you can't change import settings on
                    // builtin resources, thus the check for null
                    if (importer != null)
                    {
                        bool valid = importer.mipmapEnabled == false &&
                                     importer.alphaSource == TextureImporterAlphaSource.FromGrayScale &&
                                     importer.filterMode == FilterMode.Point &&
                                     importer.textureCompression == TextureImporterCompression.Uncompressed &&
                                     importer.textureType == TextureImporterType.SingleChannel;

                        if (!valid)
                        {
                            CoreEditorUtils.DrawFixMeBox("Invalid texture import settings.", () => SetTextureImportSettings(importer));
                        }
                    }
                }
            }

            PropertyField(m_Intensity);
            PropertyField(m_Response);
        }
Esempio n. 2
0
 internal static void DrawDiffusionProfileWarning(DiffusionProfileSettings materialProfile)
 {
     if (materialProfile != null && !HDRenderPipelineGlobalSettings.instance.diffusionProfileSettingsList.Any(d => d == materialProfile))
     {
         CoreEditorUtils.DrawFixMeBox(diffusionProfileNotInHDRPAsset, "Fix", () => HDRenderPipelineGlobalSettings.instance.AddDiffusionProfile(materialProfile));
     }
 }
Esempio n. 3
0
 internal static void FeatureHelpBox(string message, MessageType type)
 {
     CoreEditorUtils.DrawFixMeBox(message, type, "Open", () =>
     {
         Selection.activeObject = UniversalRenderPipeline.asset.scriptableRendererData;
         GUIUtility.ExitGUI();
     });
 }
Esempio n. 4
0
        internal void DrawStackSettings()
        {
            if (m_SerializedCamera.cameras.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Cannot multi edit stack of multiple cameras.", MessageType.Info);
                EditorGUILayout.EndFoldoutHeaderGroup();
                return;
            }

            bool cameraStackingAvailable = m_SerializedCamera
                                           .camerasAdditionalData
                                           .All(c => c.scriptableRenderer?.supportedRenderingFeatures?.cameraStacking ?? false);

            if (!cameraStackingAvailable)
            {
                EditorGUILayout.HelpBox("The renderer used by this camera doesn't support camera stacking. Only Base camera will render.", MessageType.Warning);
                return;
            }

            EditorGUILayout.Space();

            m_LayerList.DoLayoutList();
            m_SerializedCamera.Apply();

            EditorGUI.indentLevel--;
            if (m_TypeErrorCameras.Any())
            {
                var message = new StringBuilder();
                message.Append("The type of the following Cameras must be Overlay render type: ");
                foreach (var cam in m_TypeErrorCameras)
                {
                    message.Append(cam.name);
                    message.Append(cam != m_TypeErrorCameras.Last() ? ", " : ".");
                }

                CoreEditorUtils.DrawFixMeBox(message.ToString(), MessageType.Error, UpdateStackCamerasToOverlay);
            }

            if (m_OutputWarningCameras.Any())
            {
                var message = new StringBuilder();
                message.Append("The output properties of this Camera do not match the output properties of the following Cameras: ");
                foreach (var cam in m_OutputWarningCameras)
                {
                    message.Append(cam.name);
                    message.Append(cam != m_OutputWarningCameras.Last() ? ", " : ".");
                }

                CoreEditorUtils.DrawFixMeBox(message.ToString(), MessageType.Warning, () => UpdateStackCamerasOutput());
            }
            EditorGUI.indentLevel++;

            EditorGUILayout.Space();
        }
Esempio n. 5
0
 /// <summary>
 /// Unity calls this function when it displays the GUI. This method is sealed so you cannot override it. To implement your custom GUI, use OnMaterialGUI instead.
 /// </summary>
 /// <param name="materialEditor">Material editor instance.</param>
 /// <param name="props">The list of properties in the inspected material(s).</param>
 public sealed override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
 {
     if (!(RenderPipelineManager.currentPipeline is HDRenderPipeline))
     {
         CoreEditorUtils.DrawFixMeBox("Editing HDRP materials is only supported when an HDRP asset is assigned in the Graphics Settings", MessageType.Warning, "Open",
                                      () => SettingsService.OpenProjectSettings("Project/Graphics"));
     }
     else
     {
         OnMaterialGUI(materialEditor, props);
     }
 }
Esempio n. 6
0
        public override void OnInspectorGUI()
        {
            PropertyField(m_Mode);
            PropertyField(m_Color);

            if (m_Mode.value.intValue == (int)VignetteMode.Procedural)
            {
                PropertyField(m_Center);
                PropertyField(m_Intensity);
                PropertyField(m_Smoothness);
                PropertyField(m_Roundness);
                PropertyField(m_Rounded);
            }
            else
            {
                PropertyField(m_Mask);

                var mask = (target as Vignette).mask.value;

                // Checks import settings on the mask
                if (mask != null)
                {
                    var importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(mask)) as TextureImporter;

                    // Fails when using an internal texture as you can't change import settings on
                    // builtin resources, thus the check for null
                    if (importer != null)
                    {
                        bool valid = importer.anisoLevel == 0 &&
                                     importer.mipmapEnabled == false &&
                                     importer.alphaSource == TextureImporterAlphaSource.FromGrayScale &&
                                     importer.wrapMode == TextureWrapMode.Clamp;

                        if (!valid)
                        {
                            CoreEditorUtils.DrawFixMeBox("Invalid mask import settings.", () => SetMaskImportSettings(importer));
                        }
                    }
                }

                PropertyField(m_Opacity);
            }
        }
Esempio n. 7
0
        void DrawSections()
        {
            if (!stylizedWater.meshRenderer || !stylizedWater.meshRenderer.sharedMaterial || !stylizedWater.meshRenderer.enabled)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("Object has no active mesh renderer and/or material. Please add those first.", MessageType.Warning);
                EditorGUILayout.Space();
                return;
            }

            string name = stylizedWater.meshRenderer.sharedMaterial.shader.name;

            if (name != shaderName && name != mobileShaderName && name != underwaterShaderName)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("Material incompatible. You should add a material that uses the Stylized Water shader.", MessageType.Warning);
                EditorGUILayout.Space();
                return;
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.Space();
            switch (name)
            {
            case shaderName: EditorGUILayout.LabelField("   " + stylizedWater.material.name); break;

            case mobileShaderName: EditorGUILayout.LabelField("   " + stylizedWater.material.name + " (Mobile Variant)"); break;

            case underwaterShaderName: EditorGUILayout.LabelField("   " + stylizedWater.material.name + " (Underwater Variant)"); break;
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            CoreEditorUtils.DrawSplitter();

            if (name == shaderName || name == mobileShaderName)
            {
                colorTransparencySettings = CoreEditorUtils.DrawHeaderFoldout("Colors and Transparency", colorTransparencySettings, false, (Func <bool>)null, null);
                DrawPropertiesInspector(colorTransparencySettings, DrawColorSettings);

                DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Surface Foam"), surfaceFoamExpanded, enableSurfaceFoam, null), DrawSurfaceFoamSettings);

                DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Intersection Effects"), intersectionEffectsExpanded, enableIntersectionEffects, null), DrawIntersectionEffectSettings);
            }

            if (name == shaderName)
            {
                DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Foam Shadows"), foamShadowsExpanded, enableFoamShadows, null), DrawFoamShadowSettings);

                causticsSettings = CoreEditorUtils.DrawHeaderFoldout("Caustics", causticsSettings, false, (Func <bool>)null, null);
                DrawPropertiesInspector(causticsSettings, DrawCausticsSettings);

                planarReflectionSettings = CoreEditorUtils.DrawHeaderFoldout("Planar Reflections", planarReflectionSettings, false, (Func <bool>)null, null);
                DrawPropertiesInspector(planarReflectionSettings, DrawPlanarReflectionSettings);

                surfaceSettings = CoreEditorUtils.DrawHeaderFoldout("Surface and Lighting", surfaceSettings, false, (Func <bool>)null, null);
                DrawPropertiesInspector(surfaceSettings, DrawSurfaceSettings);
            }

            if (name == mobileShaderName || name == underwaterShaderName)
            {
                DrawPropertiesInspector(CoreEditorUtils.DrawHeaderToggle(EditorGUIUtility.TrTextContent("Refraction"), refractionExpanded, enableRefraction, null), DrawRefractionSettings);
            }

            if (name == shaderName || name == mobileShaderName)
            {
                waveSettings = CoreEditorUtils.DrawHeaderFoldout("Waves", waveSettings, false, (Func <bool>)null, null);
                DrawPropertiesInspector(waveSettings, DrawWaveSettings);
            }

            if (name == shaderName || name == underwaterShaderName)
            {
                underwaterSettings = CoreEditorUtils.DrawHeaderFoldout("Underwater", underwaterSettings, false, (Func <bool>)null, null);
                DrawPropertiesInspector(underwaterSettings, DrawUnderwaterSettings);
            }

            additionalSettings = CoreEditorUtils.DrawHeaderFoldout("Additional Settings", additionalSettings, false, (Func <bool>)null, null);
            DrawPropertiesInspector(additionalSettings, DrawAdditionalSettings);

            EditorGUILayout.Space();
            if (stylizedWater.meshRenderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On)
            {
                CoreEditorUtils.DrawFixMeBox("Water is casting shadows. \nYou should turn this off.", () => TurnOffWaterShadowCasting());
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            bool materialChanged      = false;
            bool isDefaultMaterial    = false;
            bool isValidDecalMaterial = true;

            bool isDecalSupported = DecalProjector.isSupported;

            if (!isDecalSupported)
            {
                EditorGUILayout.HelpBox("No renderer has a Decal Renderer Feature added.", MessageType.Warning);
            }

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                DoInspectorToolbar(k_EditVolumeModes, editVolumeLabels, GetBoundsGetter(target as DecalProjector), this);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();

                // Info box for tools
                GUIStyle style = new GUIStyle(EditorStyles.miniLabel);
                style.richText = true;
                GUILayout.BeginVertical(EditorStyles.helpBox);
                string helpText = k_BaseSceneEditingToolText;
                if (EditMode.editMode == k_EditShapeWithoutPreservingUV && EditMode.IsOwner(this))
                {
                    helpText = k_EditShapeWithoutPreservingUVName;
                }
                if (EditMode.editMode == k_EditShapePreservingUV && EditMode.IsOwner(this))
                {
                    helpText = k_EditShapePreservingUVName;
                }
                if (EditMode.editMode == k_EditUVAndPivot && EditMode.IsOwner(this))
                {
                    helpText = k_EditUVAndPivotName;
                }
                GUILayout.Label(helpText, style);
                GUILayout.EndVertical();
                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_ScaleMode, k_ScaleMode);

                bool negativeScale = false;
                foreach (var target in targets)
                {
                    var decalProjector = target as DecalProjector;

                    float combinedScale = decalProjector.transform.lossyScale.x * decalProjector.transform.lossyScale.y * decalProjector.transform.lossyScale.z;
                    negativeScale |= combinedScale < 0 && decalProjector.scaleMode == DecalScaleMode.InheritFromHierarchy;
                }
                if (negativeScale)
                {
                    EditorGUILayout.HelpBox("Does not work with negative odd scaling (When there are odd number of scale components)", MessageType.Warning);
                }

                var widthRect = EditorGUILayout.GetControlRect();
                EditorGUI.BeginProperty(widthRect, k_WidthContent, m_SizeValues[0]);
                EditorGUI.BeginChangeCheck();
                float newSizeX = EditorGUI.FloatField(widthRect, k_WidthContent, m_SizeValues[0].floatValue);
                if (EditorGUI.EndChangeCheck())
                {
                    UpdateSize(0, Mathf.Max(0, newSizeX));
                }
                EditorGUI.EndProperty();

                var heightRect = EditorGUILayout.GetControlRect();
                EditorGUI.BeginProperty(heightRect, k_HeightContent, m_SizeValues[1]);
                EditorGUI.BeginChangeCheck();
                float newSizeY = EditorGUI.FloatField(heightRect, k_HeightContent, m_SizeValues[1].floatValue);
                if (EditorGUI.EndChangeCheck())
                {
                    UpdateSize(1, Mathf.Max(0, newSizeY));
                }
                EditorGUI.EndProperty();

                var projectionRect = EditorGUILayout.GetControlRect();
                EditorGUI.BeginProperty(projectionRect, k_ProjectionDepthContent, m_SizeValues[2]);
                EditorGUI.BeginChangeCheck();
                float newSizeZ = EditorGUI.FloatField(projectionRect, k_ProjectionDepthContent, m_SizeValues[2].floatValue);
                if (EditorGUI.EndChangeCheck())
                {
                    UpdateSize(2, Mathf.Max(0, newSizeZ));
                }
                EditorGUI.EndProperty();

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_Offset, k_Offset);
                if (EditorGUI.EndChangeCheck())
                {
                    ReinitSavedRatioSizePivotPosition();
                }

                EditorGUILayout.Space();

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_MaterialProperty, k_MaterialContent);
                materialChanged = EditorGUI.EndChangeCheck();

                foreach (var target in targets)
                {
                    var decalProjector = target as DecalProjector;
                    var mat            = decalProjector.material;

                    isDefaultMaterial    |= decalProjector.material == DecalProjector.defaultMaterial;
                    isValidDecalMaterial &= decalProjector.IsValid();
                }

                if (m_MaterialEditor && !isValidDecalMaterial)
                {
                    CoreEditorUtils.DrawFixMeBox("Decal only work with Decal Material. Use default material or create from decal shader graph sub target.", () =>
                    {
                        m_MaterialProperty.objectReferenceValue = DecalProjector.defaultMaterial;
                        materialChanged = true;
                    });
                }

                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_UVScaleProperty, k_UVScaleContent);
                EditorGUILayout.PropertyField(m_UVBiasProperty, k_UVBiasContent);
                EditorGUILayout.PropertyField(m_FadeFactor, k_OpacityContent);
                EditorGUI.indentLevel--;

                bool angleFadeSupport = false;
                foreach (var decalProjector in targets)
                {
                    var mat = (decalProjector as DecalProjector).material;
                    if (mat == null)
                    {
                        continue;
                    }
                    angleFadeSupport = mat.HasProperty("_DecalAngleFadeSupported");
                }

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_DrawDistanceProperty, k_DistanceContent);
                if (EditorGUI.EndChangeCheck() && m_DrawDistanceProperty.floatValue < 0f)
                {
                    m_DrawDistanceProperty.floatValue = 0f;
                }

                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_FadeScaleProperty, k_FadeScaleContent);
                EditorGUI.indentLevel--;

                using (new EditorGUI.DisabledScope(!angleFadeSupport))
                {
                    float angleFadeMinValue = m_StartAngleFadeProperty.floatValue;
                    float angleFadeMaxValue = m_EndAngleFadeProperty.floatValue;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.MinMaxSlider(k_AngleFadeContent, ref angleFadeMinValue, ref angleFadeMaxValue, 0.0f, 180.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_StartAngleFadeProperty.floatValue = angleFadeMinValue;
                        m_EndAngleFadeProperty.floatValue   = angleFadeMaxValue;
                    }
                }

                if (!angleFadeSupport && isValidDecalMaterial)
                {
                    EditorGUILayout.HelpBox($"Decal Angle Fade is not enabled in Shader. In ShaderGraph enable Angle Fade option.", MessageType.Info);
                }

                EditorGUILayout.Space();
            }
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            if (materialChanged)
            {
                UpdateMaterialEditor();
            }

            if (layerMaskHasMultipleValues || layerMask != (target as Component).gameObject.layer)
            {
                foreach (var decalProjector in targets)
                {
                    (decalProjector as DecalProjector).OnValidate();
                }
            }

            if (m_MaterialEditor != null)
            {
                // We need to prevent the user to edit default decal materials
                if (isValidDecalMaterial)
                {
                    using (new DecalProjectorScope())
                    {
                        using (new EditorGUI.DisabledGroupScope(isDefaultMaterial))
                        {
                            // Draw the material's foldout and the material shader field
                            // Required to call m_MaterialEditor.OnInspectorGUI ();
                            m_MaterialEditor.DrawHeader();

                            // Draw the material properties
                            // Works only if the foldout of m_MaterialEditor.DrawHeader () is open
                            m_MaterialEditor.OnInspectorGUI();
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        public override void OnInspectorGUI()
        {
            HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

            if (!currentAsset?.currentPlatformRenderPipelineSettings.supportRayTracing ?? false)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("The current HDRP Asset does not support Ray Tracing.", MessageType.Error, wide: true);
                return;
            }

            // If ray tracing is supported display the content of the volume component
            if (HDRenderPipeline.assetSupportsRayTracing)
            {
                PropertyField(m_Enable);

                if (m_Enable.overrideState.boolValue && m_Enable.value.boolValue)
                {
                    using (new IndentLevelScope())
                    {
                        PropertyField(m_LayerMask);
                        PropertyField(m_MaxSamples);
                        PropertyField(m_MinDepth);
                        PropertyField(m_MaxDepth);
                        PropertyField(m_MaxIntensity);
                        PropertyField(m_SkyImportanceSampling);
#if ENABLE_UNITY_DENOISING_PLUGIN
                        PropertyField(m_Denoising);
                        var  denoiserType = m_Denoising.value.GetEnumValue <DenoiserType>();
                        bool supported    = Denoiser.IsDenoiserTypeSupported(denoiserType);

                        if (m_Denoising.value.intValue != (int)DenoiserType.None)
                        {
                            using (new IndentLevelScope())
                            {
                                if (supported)
                                {
                                    PropertyField(m_UseAOV);
                                    if (m_Denoising.value.intValue == (int)DenoiserType.Optix)
                                    {
                                        PropertyField(m_Temporal);
                                    }
                                }
                                else
                                {
                                    EditorGUILayout.HelpBox($"The denoiser selected is not supported by this hardware configuration.", MessageType.Error, wide: true);
                                }
                            }
                        }
#else
                        CoreEditorUtils.DrawFixMeBox("Path Tracing Denoising is not active in this project. To activate it, install the Unity Denoising Plugin package.", MessageType.Info, () =>
                        {
                            PackageManager.Client.Add("com.unity.rendering.denoising");
                        });
#endif
                    }

                    // Make sure MaxDepth is always greater or equal than MinDepth
                    m_MaxDepth.value.intValue = Math.Max(m_MinDepth.value.intValue, m_MaxDepth.value.intValue);
                }
            }
        }
        void DrawStackSettings()
        {
            m_StackSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_StackSettingsFoldout.value, Styles.stackSettingsText);
            if (m_SerializedCamera.cameras.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Cannot multi edit stack of multiple cameras.", MessageType.Info);
                EditorGUILayout.EndFoldoutHeaderGroup();
                return;
            }

            ScriptableRenderer.RenderingFeatures supportedRenderingFeatures = m_AdditionalCameraDatas[target]?.scriptableRenderer?.supportedRenderingFeatures;

            if (supportedRenderingFeatures != null && supportedRenderingFeatures.cameraStacking == false)
            {
                EditorGUILayout.HelpBox("The renderer used by this camera doesn't support camera stacking. Only Base camera will render.", MessageType.Warning);
                return;
            }

            if (m_StackSettingsFoldout.value)
            {
                m_LayerList.DoLayoutList();
                m_SerializedCamera.serializedObject.ApplyModifiedProperties();

                EditorGUI.indentLevel--;
                if (m_TypeErrorCameras.Any())
                {
                    var message = new StringBuilder();
                    message.Append("The type of the following Cameras must be Overlay render type: ");
                    foreach (var camera in m_TypeErrorCameras)
                    {
                        message.Append(camera.name);
                        if (camera != m_TypeErrorCameras.Last())
                        {
                            message.Append(", ");
                        }
                        else
                        {
                            message.Append(".");
                        }
                    }

                    CoreEditorUtils.DrawFixMeBox(message.ToString(), MessageType.Error, () => UpdateStackCemerasToOverlay());
                }

                if (m_OutputWarningCameras.Any())
                {
                    var message = new StringBuilder();
                    message.Append("The output properties of this Camera do not match the output properties of the following Cameras: ");
                    foreach (var camera in m_OutputWarningCameras)
                    {
                        message.Append(camera.name);
                        if (camera != m_OutputWarningCameras.Last())
                        {
                            message.Append(", ");
                        }
                        else
                        {
                            message.Append(".");
                        }
                    }

                    CoreEditorUtils.DrawFixMeBox(message.ToString(), MessageType.Warning, () => UpdateStackCamerasOutput());
                }
                EditorGUI.indentLevel++;

                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
        }