public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties) { // Z write doesn't work with fading bool hasZWrite = (material.GetInt("_ZWrite") != 0); if (!hasZWrite) { // Soft Particles { EditorGUI.showMixedValue = properties.softParticlesEnabled.hasMixedValue; var enabled = properties.softParticlesEnabled.floatValue; EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle(Styles.softParticlesEnabled, enabled != 0.0f) ? 1.0f : 0.0f; if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Soft Particles Enabled"); properties.softParticlesEnabled.floatValue = enabled; } if (enabled >= 0.5f) { UniversalRenderPipelineAsset urpAsset = UniversalRenderPipeline.asset; if (urpAsset != null && !urpAsset.supportsCameraDepthTexture) { GUIStyle warnStyle = new GUIStyle(GUI.skin.label); warnStyle.fontStyle = FontStyle.BoldAndItalic; warnStyle.wordWrap = true; EditorGUILayout.HelpBox("Soft Particles require depth texture. Please enable \"Depth Texture\" in the Universal Render Pipeline settings.", MessageType.Warning); } EditorGUI.indentLevel++; BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Surface Fade"), properties.softParticlesNearFadeDistance, Styles.softParticlesNearFadeDistanceText, properties.softParticlesFarFadeDistance, Styles.softParticlesFarFadeDistanceText, materialEditor); EditorGUI.indentLevel--; } } // Camera Fading { EditorGUI.showMixedValue = properties.cameraFadingEnabled.hasMixedValue; var enabled = properties.cameraFadingEnabled.floatValue; EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle(Styles.cameraFadingEnabled, enabled != 0.0f) ? 1.0f : 0.0f; if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Camera Fading Enabled"); properties.cameraFadingEnabled.floatValue = enabled; } if (enabled >= 0.5f) { EditorGUI.indentLevel++; BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Distance"), properties.cameraNearFadeDistance, Styles.cameraNearFadeDistanceText, properties.cameraFarFadeDistance, Styles.cameraFarFadeDistanceText, materialEditor); EditorGUI.indentLevel--; } } // Distortion if (properties.distortionEnabled != null) { EditorGUI.showMixedValue = properties.distortionEnabled.hasMixedValue; var enabled = properties.distortionEnabled.floatValue; EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle(Styles.distortionEnabled, enabled != 0.0f) ? 1.0f : 0.0f; if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Distortion Enabled"); properties.distortionEnabled.floatValue = enabled; } if (enabled >= 0.5f) { EditorGUI.indentLevel++; materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = properties.distortionStrength.hasMixedValue; var blend = EditorGUILayout.Slider(Styles.distortionBlend, properties.distortionBlend.floatValue, 0f, 1f); if (EditorGUI.EndChangeCheck()) { properties.distortionBlend.floatValue = blend; } EditorGUI.indentLevel--; } } EditorGUI.showMixedValue = false; } }
public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties) { // Z write doesn't work with fading bool hasZWrite = (material.GetInt("_ZWrite") != 0); if (!hasZWrite) { // Soft Particles { EditorGUI.showMixedValue = properties.softParticlesEnabled.hasMixedValue; var enabled = properties.softParticlesEnabled.floatValue; EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle(Styles.softParticlesEnabled, enabled != 0.0f) ? 1.0f : 0.0f; if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Soft Particles Enabled"); properties.softParticlesEnabled.floatValue = enabled; } if (enabled >= 0.5f) { EditorGUI.indentLevel++; BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Surface Fade"), properties.softParticlesNearFadeDistance, Styles.softParticlesNearFadeDistanceText, properties.softParticlesFarFadeDistance, Styles.softParticlesFarFadeDistanceText, materialEditor); EditorGUI.indentLevel--; } } // Camera Fading { EditorGUI.showMixedValue = properties.cameraFadingEnabled.hasMixedValue; var enabled = properties.cameraFadingEnabled.floatValue; EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle(Styles.cameraFadingEnabled, enabled != 0.0f) ? 1.0f : 0.0f; if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Camera Fading Enabled"); properties.cameraFadingEnabled.floatValue = enabled; } if (enabled >= 0.5f) { EditorGUI.indentLevel++; BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Distance"), properties.cameraNearFadeDistance, Styles.cameraNearFadeDistanceText, properties.cameraFarFadeDistance, Styles.cameraFarFadeDistanceText, materialEditor); EditorGUI.indentLevel--; } } // Distortion if (properties.distortionEnabled != null) { EditorGUI.showMixedValue = properties.distortionEnabled.hasMixedValue; var enabled = properties.distortionEnabled.floatValue; EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle(Styles.distortionEnabled, enabled != 0.0f) ? 1.0f : 0.0f; if (EditorGUI.EndChangeCheck()) { materialEditor.RegisterPropertyChangeUndo("Distortion Enabled"); properties.distortionEnabled.floatValue = enabled; } if (enabled >= 0.5f) { EditorGUI.indentLevel++; materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = properties.distortionStrength.hasMixedValue; var blend = EditorGUILayout.Slider(Styles.distortionBlend, properties.distortionBlend.floatValue, 0f, 1f); if (EditorGUI.EndChangeCheck()) { properties.distortionBlend.floatValue = blend; } EditorGUI.indentLevel--; } } EditorGUI.showMixedValue = false; } }
public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties) { // Z write doesn't work with fading bool hasZWrite = (material.GetFloat("_ZWrite") > 0.0f); if (!hasZWrite) { // Soft Particles { materialEditor.ShaderProperty(properties.softParticlesEnabled, Styles.softParticlesEnabled); if (properties.softParticlesEnabled.floatValue >= 0.5f) { UniversalRenderPipelineAsset urpAsset = UniversalRenderPipeline.asset; if (urpAsset != null && !urpAsset.supportsCameraDepthTexture) { GUIStyle warnStyle = new GUIStyle(GUI.skin.label); warnStyle.fontStyle = FontStyle.BoldAndItalic; warnStyle.wordWrap = true; EditorGUILayout.HelpBox("Soft Particles require depth texture. Please enable \"Depth Texture\" in the Universal Render Pipeline settings.", MessageType.Warning); } EditorGUI.indentLevel++; BaseShaderGUI.TwoFloatSingleLine(Styles.softParticlesFadeText, properties.softParticlesNearFadeDistance, Styles.softParticlesNearFadeDistanceText, properties.softParticlesFarFadeDistance, Styles.softParticlesFarFadeDistanceText, materialEditor); EditorGUI.indentLevel--; } } // Camera Fading { materialEditor.ShaderProperty(properties.cameraFadingEnabled, Styles.cameraFadingEnabled); if (properties.cameraFadingEnabled.floatValue >= 0.5f) { EditorGUI.indentLevel++; BaseShaderGUI.TwoFloatSingleLine(Styles.cameraFadingDistanceText, properties.cameraNearFadeDistance, Styles.cameraNearFadeDistanceText, properties.cameraFarFadeDistance, Styles.cameraFarFadeDistanceText, materialEditor); EditorGUI.indentLevel--; } } // Distortion if (properties.distortionEnabled != null) { materialEditor.ShaderProperty(properties.distortionEnabled, Styles.distortionEnabled); if (properties.distortionEnabled.floatValue >= 0.5f) { EditorGUI.indentLevel++; materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength); materialEditor.ShaderProperty(properties.distortionBlend, Styles.distortionBlend); EditorGUI.indentLevel--; } } EditorGUI.showMixedValue = false; } }