Skip to content

Commit b67f093

Browse files
arttu-peltonenEvergreen
authored andcommitted
Add change indicator to Color Curves component
Fix https://jira.unity3d.com/browse/UUM-62746 Color Curves component editor didn't indicate which curves have their overrides active in the dropdown, meaning user needs to cycle through all to find out. This PR adds indicating text suffix to the dropdown items if the curve override is active. Code is duplicated across URP and HDRP so made the change on both pipelines. What it looks like now: ![image](https://media.github.cds.internal.unity3d.com/user/3380/files/05b62714-bb1b-4e94-abaa-cd125ea0edbd) ![image](https://media.github.cds.internal.unity3d.com/user/3380/files/8375e55e-917b-4fac-b42e-1ff61ff5ded5)
1 parent 177c2b6 commit b67f093

File tree

2 files changed

+66
-24
lines changed

2 files changed

+66
-24
lines changed

Packages/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ColorCurvesEditor.cs

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ sealed class ColorCurvesEditor : VolumeComponentEditor
4040

4141
static GUIStyle s_PreLabel;
4242

43-
static GUIContent[] s_Curves =
43+
static string[] s_CurveNames =
4444
{
45-
new GUIContent("Master"),
46-
new GUIContent("Red"),
47-
new GUIContent("Green"),
48-
new GUIContent("Blue"),
49-
new GUIContent("Hue Vs Hue"),
50-
new GUIContent("Hue Vs Sat"),
51-
new GUIContent("Sat Vs Sat"),
52-
new GUIContent("Lum Vs Sat")
45+
"Master",
46+
"Red",
47+
"Green",
48+
"Blue",
49+
"Hue Vs Hue",
50+
"Hue Vs Sat",
51+
"Sat Vs Sat",
52+
"Lum Vs Sat"
5353
};
5454

5555
public override void OnEnable()
@@ -128,9 +128,28 @@ void CurveOverrideToggle(SerializedProperty overrideProp)
128128
overrideProp.boolValue = GUILayout.Toggle(overrideProp.boolValue, EditorGUIUtility.TrTextContent("Override"), EditorStyles.toolbarButton);
129129
}
130130

131+
string MakeCurveSelectionPopupLabel(int id)
132+
{
133+
string label = s_CurveNames[id];
134+
const string overrideSuffix = " (Overriding)";
135+
switch (id)
136+
{
137+
case 0: if (m_Master.overrideState.boolValue) label += overrideSuffix; break;
138+
case 1: if (m_Red.overrideState.boolValue) label += overrideSuffix; break;
139+
case 2: if (m_Green.overrideState.boolValue) label += overrideSuffix; break;
140+
case 3: if (m_Blue.overrideState.boolValue) label += overrideSuffix; break;
141+
case 4: if (m_HueVsHue.overrideState.boolValue) label += overrideSuffix; break;
142+
case 5: if (m_HueVsSat.overrideState.boolValue) label += overrideSuffix; break;
143+
case 6: if (m_SatVsSat.overrideState.boolValue) label += overrideSuffix; break;
144+
case 7: if (m_LumVsSat.overrideState.boolValue) label += overrideSuffix; break;
145+
}
146+
return label;
147+
}
148+
131149
int DoCurveSelectionPopup(int id)
132150
{
133-
GUILayout.Label(s_Curves[id], EditorStyles.toolbarPopup, GUILayout.MaxWidth(150f));
151+
var label = MakeCurveSelectionPopupLabel(id);
152+
GUILayout.Label(label, EditorStyles.toolbarPopup, GUILayout.MaxWidth(150f));
134153

135154
var lastRect = GUILayoutUtility.GetLastRect();
136155
var e = Event.current;
@@ -139,13 +158,15 @@ int DoCurveSelectionPopup(int id)
139158
{
140159
var menu = new GenericMenu();
141160

142-
for (int i = 0; i < s_Curves.Length; i++)
161+
for (int i = 0; i < s_CurveNames.Length; i++)
143162
{
144163
if (i == 4)
145164
menu.AddSeparator("");
146165

147166
int current = i; // Capture local for closure
148-
menu.AddItem(s_Curves[i], current == id, () =>
167+
168+
var menuLabel = MakeCurveSelectionPopupLabel(i);
169+
menu.AddItem(new GUIContent(menuLabel), current == id, () =>
149170
{
150171
m_SelectedCurve.intValue = current;
151172
serializedObject.ApplyModifiedProperties();

Packages/com.unity.render-pipelines.universal/Editor/Overrides/ColorCurvesEditor.cs

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ sealed class ColorCurvesEditor : VolumeComponentEditor
3737

3838
static GUIStyle s_PreLabel;
3939

40-
static GUIContent[] s_Curves =
40+
static string[] s_CurveNames =
4141
{
42-
new GUIContent("Master"),
43-
new GUIContent("Red"),
44-
new GUIContent("Green"),
45-
new GUIContent("Blue"),
46-
new GUIContent("Hue Vs Hue"),
47-
new GUIContent("Hue Vs Sat"),
48-
new GUIContent("Sat Vs Sat"),
49-
new GUIContent("Lum Vs Sat")
42+
"Master",
43+
"Red",
44+
"Green",
45+
"Blue",
46+
"Hue Vs Hue",
47+
"Hue Vs Sat",
48+
"Sat Vs Sat",
49+
"Lum Vs Sat"
5050
};
5151

5252
SavedInt m_SelectedCurve;
@@ -127,9 +127,28 @@ void CurveOverrideToggle(SerializedProperty overrideProp)
127127
overrideProp.boolValue = GUILayout.Toggle(overrideProp.boolValue, EditorGUIUtility.TrTextContent("Override"), EditorStyles.toolbarButton);
128128
}
129129

130+
string MakeCurveSelectionPopupLabel(int id)
131+
{
132+
string label = s_CurveNames[id];
133+
const string overrideSuffix = " (Overriding)";
134+
switch (id)
135+
{
136+
case 0: if (m_Master.overrideState.boolValue) label += overrideSuffix; break;
137+
case 1: if (m_Red.overrideState.boolValue) label += overrideSuffix; break;
138+
case 2: if (m_Green.overrideState.boolValue) label += overrideSuffix; break;
139+
case 3: if (m_Blue.overrideState.boolValue) label += overrideSuffix; break;
140+
case 4: if (m_HueVsHue.overrideState.boolValue) label += overrideSuffix; break;
141+
case 5: if (m_HueVsSat.overrideState.boolValue) label += overrideSuffix; break;
142+
case 6: if (m_SatVsSat.overrideState.boolValue) label += overrideSuffix; break;
143+
case 7: if (m_LumVsSat.overrideState.boolValue) label += overrideSuffix; break;
144+
}
145+
return label;
146+
}
147+
130148
int DoCurveSelectionPopup(int id)
131149
{
132-
GUILayout.Label(s_Curves[id], EditorStyles.toolbarPopup, GUILayout.MaxWidth(150f));
150+
var label = MakeCurveSelectionPopupLabel(id);
151+
GUILayout.Label(label, EditorStyles.toolbarPopup, GUILayout.MaxWidth(150f));
133152

134153
var lastRect = GUILayoutUtility.GetLastRect();
135154
var e = Event.current;
@@ -138,13 +157,15 @@ int DoCurveSelectionPopup(int id)
138157
{
139158
var menu = new GenericMenu();
140159

141-
for (int i = 0; i < s_Curves.Length; i++)
160+
for (int i = 0; i < s_CurveNames.Length; i++)
142161
{
143162
if (i == 4)
144163
menu.AddSeparator("");
145164

146165
int current = i; // Capture local for closure
147-
menu.AddItem(s_Curves[i], current == id, () =>
166+
167+
var menuLabel = MakeCurveSelectionPopupLabel(i);
168+
menu.AddItem(new GUIContent(menuLabel), current == id, () =>
148169
{
149170
m_SelectedCurve.value = current;
150171
serializedObject.ApplyModifiedProperties();

0 commit comments

Comments
 (0)