Skip to content

Commit 5214ffe

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.4] Fix a number of ShaderGraph UI/UX bugs
1 parent b1c16be commit 5214ffe

8 files changed

Lines changed: 63 additions & 17 deletions

File tree

Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/RedirectNodeView.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ public bool FindPort(SlotReference slot, out ShaderPort port)
141141
public void AttachMessage(string errString, ShaderCompilerMessageSeverity severity)
142142
{
143143
ClearMessage();
144-
IconBadge badge;
145-
badge = IconBadge.CreateComment(errString);
144+
IconBadge badge = InternalBridge.IconBadge.CreateComment(errString);
146145

147146
Add(badge);
148147
badge.AttachTo(outputContainer, SpriteAlignment.RightCenter);

Packages/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ public void AttachMessage(string errString, ShaderCompilerMessageSeverity severi
195195
IconBadge badge;
196196
if (severity == ShaderCompilerMessageSeverity.Error)
197197
{
198-
badge = IconBadge.CreateError(errString);
198+
badge = InternalBridge.IconBadge.CreateError(errString);
199199
}
200200
else
201201
{
202-
badge = IconBadge.CreateComment(errString);
202+
badge = InternalBridge.IconBadge.CreateComment(errString);
203203
}
204204

205205
Add(badge);

Packages/com.unity.shadergraph/Editor/Drawing/Views/PropertyNodeView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ public void AttachMessage(string errString, ShaderCompilerMessageSeverity severi
326326
IconBadge badge;
327327
if (severity == ShaderCompilerMessageSeverity.Error)
328328
{
329-
badge = IconBadge.CreateError(errString);
329+
badge = InternalBridge.IconBadge.CreateError(errString);
330330
}
331331
else
332332
{
333-
badge = IconBadge.CreateComment(errString);
333+
badge = InternalBridge.IconBadge.CreateComment(errString);
334334
}
335335

336336
Add(badge);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using GraphViewIconBadge = UnityEditor.Experimental.GraphView.IconBadge;
2+
3+
namespace UnityEditor.ShaderGraph.InternalBridge
4+
{
5+
// Wrapper class for internal access to GraphView's IconBadge.
6+
// Allows for creation of badges which don't manually layout their label's dimensions. Works around
7+
// a GraphView bug.
8+
internal static class IconBadge
9+
{
10+
public static GraphViewIconBadge CreateError(string message)
11+
{
12+
var result = GraphViewIconBadge.CreateError(message);
13+
result.m_ComputeTextBoundingBox = false;
14+
return result;
15+
}
16+
17+
public static GraphViewIconBadge CreateComment(string message)
18+
{
19+
var result = GraphViewIconBadge.CreateComment(message);
20+
result.m_ComputeTextBoundingBox = false;
21+
return result;
22+
}
23+
}
24+
}

Packages/com.unity.shadergraph/Editor/InternalBridge/IconBadge.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.unity.shadergraph/Editor/Resources/Styles/Controls/MultiFloatControlView.uss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ MultiFloatControlView > #dummy > Label {
1414

1515

1616
.unity-base-field {
17-
min-width: 30px;
18-
flex-grow: 1;
17+
width: 30px;
1918
margin-top: 1px;
2019
margin-bottom: 1px;
2120
margin-left: 0;

Packages/com.unity.shadergraph/Editor/Resources/Styles/MaterialNodeView.uss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ MaterialNodeView #controls > #items {
4141
padding-bottom: 4px;
4242
}
4343

44+
/* Stop dropdown properties from overflowing the node's container */
45+
MaterialNodeView PropertyRow > #container > #label {
46+
min-width: 92px;
47+
}
48+
4449
MaterialNodeView #title {
4550
padding-top: 8px;
4651
border-bottom-width: 8px;

Packages/com.unity.shadergraph/Editor/ShaderGraphPreferences.cs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ static class Keys
3535
internal const string newNodesPreview = "UnityEditor.ShaderGraph.NewNodesPreview";
3636
}
3737

38+
// Note that GUIContent in this class is used to generate search keywords for the preferences window
39+
class Labels
40+
{
41+
public static GUIContent previewVariantLimit = new GUIContent("Preview Variant Limit");
42+
public static GUIContent autoAddRemoveBlocks = new GUIContent("Automatically Add and Remove Block Nodes");
43+
public static GUIContent allowDeprecatedBehaviors = new GUIContent("Enable Deprecated Nodes");
44+
public static GUIContent zoomStepSize = new GUIContent("Zoom Step Size", "Default is 0.5");
45+
public static GUIContent graphTemplateWorkflow = new GUIContent("Graph Template Workflow",
46+
"When creating a new Shadergraph asset from specific menu items, determine if a reference should use a"
47+
+ " variant of the newly created material sub-asset or the shader itself.");
48+
public static GUIContent openNewGraphOnCreation = new GUIContent("Open new Shader Graphs automatically",
49+
"Choose whether new ShaderGraph assets should automatically open for editing.");
50+
public static GUIContent newNodesPreview = new GUIContent("Expand Node Preview on Node creation",
51+
"Choose whether newly added Nodes' Previews should be expanded.");
52+
}
53+
3854
static bool m_Loaded = false;
3955
internal delegate void PreferenceChangedDelegate();
4056

@@ -142,7 +158,8 @@ static SettingsProvider PreferenceGUI()
142158
{
143159
return new SettingsProvider("Preferences/Shader Graph", SettingsScope.User)
144160
{
145-
guiHandler = searchContext => OpenGUI()
161+
guiHandler = searchContext => OpenGUI(),
162+
keywords = SettingsProvider.GetSearchKeywordsFromGUIContentProperties<Labels>(),
146163
};
147164
}
148165

@@ -159,8 +176,8 @@ static void OpenGUI()
159176
var willPreviewVariantBeIgnored = ShaderGraphPreferences.previewVariantLimit > actualLimit || ShaderGraphProjectSettings.instance.overrideShaderVariantLimit;
160177

161178
var variantLimitLabel = willPreviewVariantBeIgnored
162-
? new GUIContent("Preview Variant Limit", EditorGUIUtility.IconContent("console.infoicon").image, $"The Preview Variant Limit is higher than the Shader Variant Limit in Project Settings: {actualLimit}. The Preview Variant Limit will be ignored.")
163-
: new GUIContent("Preview Variant Limit");
179+
? new GUIContent(Labels.previewVariantLimit.text, EditorGUIUtility.IconContent("console.infoicon").image, $"The Preview Variant Limit is higher than the Shader Variant Limit in Project Settings: {actualLimit}. The Preview Variant Limit will be ignored.")
180+
: Labels.previewVariantLimit;
164181

165182
EditorGUI.BeginChangeCheck();
166183
var variantLimitValue = EditorGUILayout.DelayedIntField(variantLimitLabel, previewVariantLimit);
@@ -171,42 +188,42 @@ static void OpenGUI()
171188
}
172189

173190
EditorGUI.BeginChangeCheck();
174-
var autoAddRemoveBlocksValue = EditorGUILayout.Toggle("Automatically Add and Remove Block Nodes", autoAddRemoveBlocks);
191+
var autoAddRemoveBlocksValue = EditorGUILayout.Toggle(Labels.autoAddRemoveBlocks, autoAddRemoveBlocks);
175192
if (EditorGUI.EndChangeCheck())
176193
{
177194
autoAddRemoveBlocks = autoAddRemoveBlocksValue;
178195
}
179196

180197
EditorGUI.BeginChangeCheck();
181-
var allowDeprecatedBehaviorsValue = EditorGUILayout.Toggle("Enable Deprecated Nodes", allowDeprecatedBehaviors);
198+
var allowDeprecatedBehaviorsValue = EditorGUILayout.Toggle(Labels.allowDeprecatedBehaviors, allowDeprecatedBehaviors);
182199
if (EditorGUI.EndChangeCheck())
183200
{
184201
allowDeprecatedBehaviors = allowDeprecatedBehaviorsValue;
185202
}
186203

187204
EditorGUI.BeginChangeCheck();
188-
var zoomStepSizeValue = EditorGUILayout.Slider(new GUIContent("Zoom Step Size", $"Default is 0.5"), zoomStepSize, 0.0f, 1f);
205+
var zoomStepSizeValue = EditorGUILayout.Slider(Labels.zoomStepSize.text, zoomStepSize, 0.0f, 1f);
189206
if (EditorGUI.EndChangeCheck())
190207
{
191208
zoomStepSize = zoomStepSizeValue;
192209
}
193210

194211
EditorGUI.BeginChangeCheck();
195-
var graphTemplateWorkflowValue = EditorGUILayout.EnumPopup(new GUIContent("Graph Template Workflow", "When creating a new Shadergraph asset from specific menu items, determine if a reference should use a variant of the newly created material sub-asset or the shader itself."), graphTemplateWorkflow);
212+
var graphTemplateWorkflowValue = EditorGUILayout.EnumPopup(Labels.graphTemplateWorkflow, graphTemplateWorkflow);
196213
if (EditorGUI.EndChangeCheck())
197214
{
198215
graphTemplateWorkflow = (GraphTemplateWorkflow)graphTemplateWorkflowValue;
199216
}
200217

201218
EditorGUI.BeginChangeCheck();
202-
var openNewGraphOnCreationValue = EditorGUILayout.Toggle(new GUIContent("Open new Shader Graphs automatically", "Choose whether new ShaderGraph assets should automatically open for editing."), openNewGraphOnCreation);
219+
var openNewGraphOnCreationValue = EditorGUILayout.Toggle(Labels.openNewGraphOnCreation, openNewGraphOnCreation);
203220
if (EditorGUI.EndChangeCheck())
204221
{
205222
openNewGraphOnCreation = openNewGraphOnCreationValue;
206223
}
207224

208225
EditorGUI.BeginChangeCheck();
209-
var newNodesPreviewValue = EditorGUILayout.Toggle(new GUIContent("Expand Node Preview on Node creation", "Choose whether newly added Nodes' Previews should be expanded."), newNodesPreview);
226+
var newNodesPreviewValue = EditorGUILayout.Toggle(Labels.newNodesPreview, newNodesPreview);
210227
if (EditorGUI.EndChangeCheck())
211228
{
212229
newNodesPreview = newNodesPreviewValue;

0 commit comments

Comments
 (0)