diff --git a/Packages/src/Editor/UIEffectProjectSettingsEditor.cs b/Packages/src/Editor/UIEffectProjectSettingsEditor.cs index 52ffde7..dfb3db7 100644 --- a/Packages/src/Editor/UIEffectProjectSettingsEditor.cs +++ b/Packages/src/Editor/UIEffectProjectSettingsEditor.cs @@ -16,6 +16,7 @@ namespace Coffee.UIEffects.Editors private SerializedProperty _runtimePresets; private SerializedProperty _runtimePresetsV2; private SerializedProperty _useHDRColorPicker; + private SerializedProperty _enableColorCorrection; private ShaderVariantRegistryEditor _shaderVariantRegistryEditor; private UIEffect[] _legacyPresets; private bool _expandRuntimePresets; @@ -25,6 +26,7 @@ namespace Coffee.UIEffects.Editors { base.OnEnable(); _legacyPresets = UIEffectProjectSettings.LoadEditorPresets(); + _enableColorCorrection = serializedObject.FindProperty("m_EnableColorCorrection"); _useHDRColorPicker = serializedObject.FindProperty("m_UseHDRColorPicker"); _runtimePresets = serializedObject.FindProperty("m_RuntimePresets"); _runtimePresetsV2 = serializedObject.FindProperty("m_RuntimePresetsV2"); @@ -69,6 +71,17 @@ namespace Coffee.UIEffects.Editors // Legacy Presets DrawLegacyPresets(); + // Settings + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(_enableColorCorrection); + if (EditorGUI.EndChangeCheck()) + { + foreach (var g in Misc.FindObjectsOfType()) + { + g.SetMaterialContextAllDirty(); + } + } + // Editor // Use HDR color pickers. EditorGUILayout.PropertyField(_useHDRColorPicker); diff --git a/Packages/src/Runtime/UIEffectBase.cs b/Packages/src/Runtime/UIEffectBase.cs index a34b75b..50c2298 100644 --- a/Packages/src/Runtime/UIEffectBase.cs +++ b/Packages/src/Runtime/UIEffectBase.cs @@ -288,6 +288,13 @@ namespace Coffee.UIEffects _isContextDirty = true; } + public void SetMaterialContextAllDirty() + { + _isContextDirty = true; + context.SetGradationDirty(); + context.SetTransitionGradationDirty(); + } + internal void ReleaseMaterial() { MaterialRepository.Release(ref _material); diff --git a/Packages/src/Runtime/UIEffectContext.cs b/Packages/src/Runtime/UIEffectContext.cs index 19740c9..eb112a2 100644 --- a/Packages/src/Runtime/UIEffectContext.cs +++ b/Packages/src/Runtime/UIEffectContext.cs @@ -852,7 +852,15 @@ namespace Coffee.UIEffects private static Color ApplyColorSpace(Color color) { - return QualitySettings.activeColorSpace == ColorSpace.Linear ? color : color.gamma; + // v5.11.9 or later, color correction is applied to the color filter and gradation colors. + if (UIEffectProjectSettings.enableColorCorrection) + { + return QualitySettings.activeColorSpace == ColorSpace.Linear ? color : color.gamma; + } + else + { + return QualitySettings.activeColorSpace == ColorSpace.Linear ? color.linear : color; + } } } } diff --git a/Packages/src/Runtime/UIEffectProjectSettings.cs b/Packages/src/Runtime/UIEffectProjectSettings.cs index 49e32b9..f9c619b 100644 --- a/Packages/src/Runtime/UIEffectProjectSettings.cs +++ b/Packages/src/Runtime/UIEffectProjectSettings.cs @@ -21,6 +21,12 @@ namespace Coffee.UIEffects [SerializeField] internal List m_RuntimePresetsV2 = new List(); + [Header("Settings")] + [Tooltip("Whether to enable the color correction feature added in v5.11.9.\n" + + "If disabled, the color picker will not display the correct colors, but compatibility with previous versions can be maintained.")] + [HideInInspector] + [SerializeField] private bool m_EnableColorCorrection = true; + [Header("Editor")] [Tooltip("Use HDR color pickers on color fields.")] [HideInInspector] @@ -38,6 +44,16 @@ namespace Coffee.UIEffects public static ShaderVariantCollection shaderVariantCollection => shaderRegistry.shaderVariantCollection; + /// + /// Whether to enable the color correction feature added in v5.11.9. + /// If disabled, the color picker will not display the correct colors, but compatibility with previous + /// versions can be maintained. + /// + public static bool enableColorCorrection => instance.m_EnableColorCorrection; + + /// + /// Whether to use HDR color pickers on color fields. + /// public static bool useHdrColorPicker { get => instance.m_UseHDRColorPicker;