fix: Added an option to Project Settings to disable color correction and revert to the color output used in version 5.11.8 or earlier

close #414
This commit is contained in:
mob-sakai
2026-11-24 14:50:59 +09:00
parent 76f1478523
commit aa0bf72bd4
4 changed files with 45 additions and 1 deletions
@@ -16,6 +16,7 @@ namespace Coffee.UIEffects.Editors
private SerializedProperty _runtimePresets; private SerializedProperty _runtimePresets;
private SerializedProperty _runtimePresetsV2; private SerializedProperty _runtimePresetsV2;
private SerializedProperty _useHDRColorPicker; private SerializedProperty _useHDRColorPicker;
private SerializedProperty _enableColorCorrection;
private ShaderVariantRegistryEditor _shaderVariantRegistryEditor; private ShaderVariantRegistryEditor _shaderVariantRegistryEditor;
private UIEffect[] _legacyPresets; private UIEffect[] _legacyPresets;
private bool _expandRuntimePresets; private bool _expandRuntimePresets;
@@ -25,6 +26,7 @@ namespace Coffee.UIEffects.Editors
{ {
base.OnEnable(); base.OnEnable();
_legacyPresets = UIEffectProjectSettings.LoadEditorPresets(); _legacyPresets = UIEffectProjectSettings.LoadEditorPresets();
_enableColorCorrection = serializedObject.FindProperty("m_EnableColorCorrection");
_useHDRColorPicker = serializedObject.FindProperty("m_UseHDRColorPicker"); _useHDRColorPicker = serializedObject.FindProperty("m_UseHDRColorPicker");
_runtimePresets = serializedObject.FindProperty("m_RuntimePresets"); _runtimePresets = serializedObject.FindProperty("m_RuntimePresets");
_runtimePresetsV2 = serializedObject.FindProperty("m_RuntimePresetsV2"); _runtimePresetsV2 = serializedObject.FindProperty("m_RuntimePresetsV2");
@@ -69,6 +71,17 @@ namespace Coffee.UIEffects.Editors
// Legacy Presets // Legacy Presets
DrawLegacyPresets(); DrawLegacyPresets();
// Settings
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_enableColorCorrection);
if (EditorGUI.EndChangeCheck())
{
foreach (var g in Misc.FindObjectsOfType<UIEffect>())
{
g.SetMaterialContextAllDirty();
}
}
// Editor // Editor
// Use HDR color pickers. // Use HDR color pickers.
EditorGUILayout.PropertyField(_useHDRColorPicker); EditorGUILayout.PropertyField(_useHDRColorPicker);
+7
View File
@@ -288,6 +288,13 @@ namespace Coffee.UIEffects
_isContextDirty = true; _isContextDirty = true;
} }
public void SetMaterialContextAllDirty()
{
_isContextDirty = true;
context.SetGradationDirty();
context.SetTransitionGradationDirty();
}
internal void ReleaseMaterial() internal void ReleaseMaterial()
{ {
MaterialRepository.Release(ref _material); MaterialRepository.Release(ref _material);
+8
View File
@@ -851,8 +851,16 @@ namespace Coffee.UIEffects
} }
private static Color ApplyColorSpace(Color color) private static Color ApplyColorSpace(Color color)
{
// 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; return QualitySettings.activeColorSpace == ColorSpace.Linear ? color : color.gamma;
} }
else
{
return QualitySettings.activeColorSpace == ColorSpace.Linear ? color.linear : color;
}
}
} }
} }
@@ -21,6 +21,12 @@ namespace Coffee.UIEffects
[SerializeField] [SerializeField]
internal List<UIEffectPreset> m_RuntimePresetsV2 = new List<UIEffectPreset>(); internal List<UIEffectPreset> m_RuntimePresetsV2 = new List<UIEffectPreset>();
[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")] [Header("Editor")]
[Tooltip("Use HDR color pickers on color fields.")] [Tooltip("Use HDR color pickers on color fields.")]
[HideInInspector] [HideInInspector]
@@ -38,6 +44,16 @@ namespace Coffee.UIEffects
public static ShaderVariantCollection shaderVariantCollection => shaderRegistry.shaderVariantCollection; public static ShaderVariantCollection shaderVariantCollection => shaderRegistry.shaderVariantCollection;
/// <summary>
/// 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.
/// </summary>
public static bool enableColorCorrection => instance.m_EnableColorCorrection;
/// <summary>
/// Whether to use HDR color pickers on color fields.
/// </summary>
public static bool useHdrColorPicker public static bool useHdrColorPicker
{ {
get => instance.m_UseHDRColorPicker; get => instance.m_UseHDRColorPicker;