mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-12-01 10:12:38 +08:00
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:
@@ -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<UIEffect>())
|
||||
{
|
||||
g.SetMaterialContextAllDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Editor
|
||||
// Use HDR color pickers.
|
||||
EditorGUILayout.PropertyField(_useHDRColorPicker);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,12 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
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")]
|
||||
[Tooltip("Use HDR color pickers on color fields.")]
|
||||
[HideInInspector]
|
||||
@@ -38,6 +44,16 @@ namespace Coffee.UIEffects
|
||||
|
||||
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
|
||||
{
|
||||
get => instance.m_UseHDRColorPicker;
|
||||
|
||||
Reference in New Issue
Block a user