A game about forced loneliness, made by TACStudios
1
2using System;
3using System.Collections.Generic;
4using System.Reflection;
5using System.Text;
6using UnityEditor.Experimental.GraphView;
7using UnityEditor.ShaderGraph.Drawing;
8using UnityEditor.ShortcutManagement;
9using UnityEngine;
10using UnityEngine.UIElements;
11
12namespace UnityEditor.ShaderGraph
13{
14 static class ShaderGraphShortcuts
15 {
16 static MaterialGraphEditWindow GetFocusedShaderGraphEditorWindow()
17 {
18 return EditorWindow.focusedWindow as MaterialGraphEditWindow;
19 }
20
21 static GraphEditorView GetGraphEditorView()
22 {
23 return GetFocusedShaderGraphEditorWindow().graphEditorView;
24 }
25
26 static MaterialGraphView GetGraphView()
27 {
28 return GetGraphEditorView().graphView;
29 }
30
31 static bool GetMousePositionIsInGraphView(out Vector2 pos)
32 {
33 pos = default;
34 var graphView = GetGraphView();
35 var windowRoot = GetFocusedShaderGraphEditorWindow().rootVisualElement;
36 var windowMousePosition = windowRoot.ChangeCoordinatesTo(windowRoot.parent, graphView.cachedMousePosition);
37
38 if (!graphView.worldBound.Contains(windowMousePosition))
39 return false; // don't create nodes if they aren't on the graph view.
40
41 pos = graphView.contentViewContainer.WorldToLocal(graphView.cachedMousePosition);
42 return true;
43 }
44
45 static void CreateNode<T>() where T : AbstractMaterialNode
46 {
47 if (!GetMousePositionIsInGraphView(out var graphMousePosition))
48 return;
49
50 var positionRect = new Rect(graphMousePosition, Vector2.zero);
51
52 var graphView = GetGraphView();
53 var graph = graphView.graph;
54 AbstractMaterialNode node = Activator.CreateInstance<T>();
55
56 var drawState = node.drawState;
57 drawState.position = positionRect;
58 node.drawState = drawState;
59
60 graph.owner.RegisterCompleteObjectUndo("Add " + node.name);
61 graphView.graph.AddNode(node);
62 }
63
64 static HashSet<(KeyCode key, ShortcutModifiers modifier)> reservedShortcuts = new HashSet<(KeyCode key, ShortcutModifiers modifier)> {
65 (KeyCode.A, ShortcutModifiers.None), // Frame All
66 (KeyCode.F, ShortcutModifiers.None), // Frame Selection
67 (KeyCode.Space, ShortcutModifiers.None), // Summon Searcher (for node creation)
68 (KeyCode.C, ShortcutModifiers.Action), // Copy
69 (KeyCode.X, ShortcutModifiers.Action), // cut
70 (KeyCode.V, ShortcutModifiers.Action), // Paste
71 (KeyCode.Z, ShortcutModifiers.Action), // Undo
72 (KeyCode.Y, ShortcutModifiers.Action), // Redo
73 (KeyCode.D, ShortcutModifiers.Action), // Duplicate
74 };
75
76 static void CheckBindings(string name)
77 {
78 if (!ShortcutManager.instance.IsShortcutOverridden(name))
79 return;
80
81 var customBinding = ShortcutManager.instance.GetShortcutBinding(name);
82
83 foreach(var keyCombo in customBinding.keyCombinationSequence)
84 {
85 if (reservedShortcuts.Contains((keyCombo.keyCode, keyCombo.modifiers)))
86 {
87 throw new Exception($"The binding for {name} ({keyCombo}) conflicts with a built-in shortcut. Please go to Edit->Shortcuts... and change the binding.");
88 }
89 }
90 }
91
92 internal static string GetKeycodeForContextMenu(string id)
93 {
94 const string kKeycodePrefixAlt = "&";
95 const string kKeycodePrefixShift = "#";
96 const string kKeycodePrefixAction = "%";
97 const string kKeycodePrefixControl = "^";
98 const string kKeycodePrefixNoModifier = "_";
99
100 var binding = ShortcutManager.instance.GetShortcutBinding(id);
101 foreach (var keyCombo in binding.keyCombinationSequence)
102 {
103 var sb = new StringBuilder();
104
105 if (keyCombo.alt) sb.Append(kKeycodePrefixAlt);
106 if (keyCombo.shift) sb.Append(kKeycodePrefixShift);
107 if (keyCombo.action) sb.Append(kKeycodePrefixAction);
108 if (keyCombo.control) sb.Append(kKeycodePrefixControl);
109 if (keyCombo.modifiers == ShortcutModifiers.None) sb.Append(kKeycodePrefixNoModifier);
110
111 sb.Append(keyCombo.keyCode);
112 return sb.ToString();
113 }
114
115 return "";
116 }
117
118 #region File
119 [Shortcut("ShaderGraph/File: Save", typeof(MaterialGraphEditWindow), KeyCode.S, ShortcutModifiers.Action)]
120 static void Save(ShortcutArguments args)
121 {
122 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
123 GetFocusedShaderGraphEditorWindow().SaveAsset();
124 }
125
126 [Shortcut("ShaderGraph/File: Save As...", typeof(MaterialGraphEditWindow), KeyCode.S, ShortcutModifiers.Action | ShortcutModifiers.Shift)]
127 static void SaveAs(ShortcutArguments args)
128 {
129 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
130 GetFocusedShaderGraphEditorWindow().SaveAs();
131 }
132
133 [Shortcut("ShaderGraph/File: Close Tab", typeof(MaterialGraphEditWindow), KeyCode.F4, ShortcutModifiers.Action)]
134 static void CloseTab(ShortcutArguments args)
135 {
136 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
137 var editorWindow = GetFocusedShaderGraphEditorWindow();
138 if (editorWindow.PromptSaveIfDirtyOnQuit())
139 editorWindow.Close();
140 }
141
142 #endregion
143
144 #region Toolbar
145 [Shortcut("ShaderGraph/Toolbar: Toggle Blackboard", typeof(MaterialGraphEditWindow), KeyCode.Alpha1, ShortcutModifiers.Shift)]
146 static void ToggleBlackboard(ShortcutArguments args)
147 {
148 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
149 var graphEditor = GetGraphEditorView();
150 graphEditor.viewSettings.isBlackboardVisible = !graphEditor.viewSettings.isBlackboardVisible;
151 graphEditor.UserViewSettingsChangeCheck(graphEditor.colorManager.activeIndex);
152 }
153
154 [Shortcut("ShaderGraph/Toolbar: Toggle Inspector", typeof(MaterialGraphEditWindow), KeyCode.Alpha2, ShortcutModifiers.Shift)]
155 static void ToggleInspector(ShortcutArguments args)
156 {
157 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
158 var graphEditor = GetGraphEditorView();
159 graphEditor.viewSettings.isInspectorVisible = !graphEditor.viewSettings.isInspectorVisible;
160 graphEditor.UserViewSettingsChangeCheck(graphEditor.colorManager.activeIndex);
161 }
162
163 [Shortcut("ShaderGraph/Toolbar: Toggle Main Preview", typeof(MaterialGraphEditWindow), KeyCode.Alpha3, ShortcutModifiers.Shift)]
164 static void ToggleMainPreview(ShortcutArguments args)
165 {
166 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
167 var graphEditor = GetGraphEditorView();
168 graphEditor.viewSettings.isPreviewVisible = !graphEditor.viewSettings.isPreviewVisible;
169 graphEditor.UserViewSettingsChangeCheck(graphEditor.colorManager.activeIndex);
170 }
171
172 [Shortcut("ShaderGraph/Toolbar: Cycle Color Mode", typeof(MaterialGraphEditWindow), KeyCode.Alpha4, ShortcutModifiers.Shift)]
173 static void CycleColorMode(ShortcutArguments args)
174 {
175 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
176 var graphEditor = GetGraphEditorView();
177
178 var nextIndex = graphEditor.colorManager.activeIndex + 1;
179 if (nextIndex >= graphEditor.colorManager.providersCount)
180 nextIndex = 0;
181
182 graphEditor.UserViewSettingsChangeCheck(nextIndex);
183 }
184 #endregion
185
186 #region Selection
187 internal const string summonDocumentationShortcutID = "ShaderGraph/Selection: Summon Documentation";
188 [Shortcut(summonDocumentationShortcutID, typeof(MaterialGraphEditWindow), KeyCode.F1)]
189 static void Documentation(ShortcutArguments args)
190 {
191 CheckBindings(summonDocumentationShortcutID);
192 foreach (var selected in GetGraphView().selection)
193 if (selected is IShaderNodeView nodeView && nodeView.node.documentationURL != null)
194 {
195 System.Diagnostics.Process.Start(nodeView.node.documentationURL);
196 break;
197 }
198 }
199
200 internal const string nodeGroupShortcutID = "ShaderGraph/Selection: Node Group";
201 [Shortcut(nodeGroupShortcutID, typeof(MaterialGraphEditWindow), KeyCode.G, ShortcutModifiers.Action)]
202 static void Group(ShortcutArguments args)
203 {
204 CheckBindings(nodeGroupShortcutID);
205 var graphView = GetGraphView();
206 foreach(var selected in graphView.selection)
207 if ((selected is IShaderNodeView nodeView && nodeView.node is AbstractMaterialNode)
208 || selected.GetType() == typeof(Drawing.StickyNote))
209 {
210 graphView.GroupSelection();
211 break;
212 }
213 }
214
215 internal const string nodeUnGroupShortcutID = "ShaderGraph/Selection: Node Ungroup";
216 [Shortcut(nodeUnGroupShortcutID, typeof(MaterialGraphEditWindow), KeyCode.U, ShortcutModifiers.Action)]
217 static void UnGroup(ShortcutArguments args)
218 {
219 CheckBindings(nodeUnGroupShortcutID);
220 var graphView = GetGraphView();
221 foreach (var selected in graphView.selection)
222 if ((selected is IShaderNodeView nodeView && nodeView.node is AbstractMaterialNode)
223 || selected.GetType() == typeof(Drawing.StickyNote))
224 {
225 graphView.RemoveFromGroupNode();
226 break;
227 }
228 }
229
230 internal const string nodePreviewShortcutID = "ShaderGraph/Selection: Toggle Node Previews";
231 [Shortcut(nodePreviewShortcutID, typeof(MaterialGraphEditWindow), KeyCode.T, ShortcutModifiers.Action)]
232 static void ToggleNodePreviews(ShortcutArguments args)
233 {
234 CheckBindings(nodePreviewShortcutID);
235 bool shouldHide = false;
236 // Toggle all node previews if none are selected. Otherwise, update only the selected node previews.
237 var selection = GetGraphView().selection;
238 if (selection.Count == 0)
239 {
240 var graph = GetGraphView().graph;
241 var nodes = graph.GetNodes<AbstractMaterialNode>();
242 foreach (AbstractMaterialNode node in nodes)
243 if (node.previewExpanded && node.hasPreview)
244 {
245 shouldHide = true;
246 break;
247 }
248
249 graph.owner.RegisterCompleteObjectUndo("Toggle Previews");
250 foreach (AbstractMaterialNode node in nodes)
251 node.previewExpanded = !shouldHide;
252 }
253 else
254 {
255 foreach (var selected in selection)
256 if (selected is IShaderNodeView nodeView)
257 {
258 if (nodeView.node.previewExpanded && nodeView.node.hasPreview)
259 {
260 shouldHide = true;
261 break;
262 }
263 }
264 GetGraphView().SetPreviewExpandedForSelectedNodes(!shouldHide);
265 }
266 }
267
268 internal const string nodeCollapsedShortcutID = "ShaderGraph/Selection: Toggle Node Collapsed";
269 [Shortcut(nodeCollapsedShortcutID, typeof(MaterialGraphEditWindow), KeyCode.P, ShortcutModifiers.Action)]
270 static void ToggleNodeCollapsed(ShortcutArguments args)
271 {
272 CheckBindings(nodeCollapsedShortcutID);
273 bool shouldCollapse = false;
274 foreach (var selected in GetGraphView().selection)
275 if (selected is MaterialNodeView nodeView)
276 {
277 if (nodeView.expanded && nodeView.CanToggleNodeExpanded())
278 {
279 shouldCollapse = true;
280 break;
281 }
282 }
283 GetGraphView().SetNodeExpandedForSelectedNodes(!shouldCollapse);
284 }
285
286 internal const string createRedirectNodeShortcutID = "ShaderGraph/Selection: Insert Redirect";
287 [Shortcut(createRedirectNodeShortcutID, typeof(MaterialGraphEditWindow), KeyCode.R, ShortcutModifiers.Action)]
288 static void InsertRedirect(ShortcutArguments args)
289 {
290 CheckBindings(createRedirectNodeShortcutID);
291
292 if (!GetMousePositionIsInGraphView(out var graphMousePosition))
293 return;
294
295 foreach (var selected in GetGraphView().selection)
296 {
297 if (selected is Edge edge)
298 {
299 int weight = 1;
300 var pos = graphMousePosition * weight;
301 int count = weight;
302 foreach(var cp in edge.edgeControl.controlPoints)
303 {
304 pos += cp;
305 count++;
306 }
307 pos /= count;
308 pos = GetGraphView().contentViewContainer.LocalToWorld(pos);
309 GetGraphView().CreateRedirectNode(pos, edge);
310 }
311 }
312 }
313 #endregion
314
315 #region Add Specific Node
316
317 [Shortcut("ShaderGraph/Add Node: Lerp", typeof(MaterialGraphEditWindow), KeyCode.L, ShortcutModifiers.Alt)]
318 static void CreateLerp(ShortcutArguments args)
319 {
320 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
321 CreateNode<LerpNode>();
322 }
323
324 [Shortcut("ShaderGraph/Add Node: Multiply", typeof(MaterialGraphEditWindow), KeyCode.M, ShortcutModifiers.Alt)]
325 static void CreateMultiply(ShortcutArguments args)
326 {
327 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
328 CreateNode<MultiplyNode>();
329 }
330
331 [Shortcut("ShaderGraph/Add Node: Add", typeof(MaterialGraphEditWindow), KeyCode.A, ShortcutModifiers.Alt)]
332 static void CreateAdd(ShortcutArguments args)
333 {
334 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
335 CreateNode<AddNode>();
336 }
337
338 [Shortcut("ShaderGraph/Add Node: Sample Texture 2D", typeof(MaterialGraphEditWindow), KeyCode.X, ShortcutModifiers.Alt)]
339 static void CreateSampleTexture2D(ShortcutArguments args)
340 {
341 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
342 CreateNode<SampleTexture2DNode>();
343 }
344
345 [Shortcut("ShaderGraph/Add Node: Float", typeof(MaterialGraphEditWindow), KeyCode.Alpha1, ShortcutModifiers.Alt)]
346 static void CreateFloat(ShortcutArguments args)
347 {
348 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
349 CreateNode<Vector1Node>();
350 }
351
352 [Shortcut("ShaderGraph/Add Node: Vector2", typeof(MaterialGraphEditWindow), KeyCode.Alpha2, ShortcutModifiers.Alt)]
353 static void CreateVec2(ShortcutArguments args)
354 {
355 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
356 CreateNode<Vector2Node>();
357 }
358
359 [Shortcut("ShaderGraph/Add Node: Vector3", typeof(MaterialGraphEditWindow), KeyCode.Alpha3, ShortcutModifiers.Alt)]
360 static void CreateVec3(ShortcutArguments args)
361 {
362 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
363 CreateNode<Vector3Node>();
364 }
365
366 [Shortcut("ShaderGraph/Add Node: Vector4", typeof(MaterialGraphEditWindow), KeyCode.Alpha4, ShortcutModifiers.Alt)]
367 static void CreateVec4(ShortcutArguments args)
368 {
369 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
370 CreateNode<Vector4Node>();
371 }
372
373 [Shortcut("ShaderGraph/Add Node: Split", typeof(MaterialGraphEditWindow), KeyCode.E, ShortcutModifiers.Alt)]
374 static void CreateSplit(ShortcutArguments args)
375 {
376 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
377 CreateNode<SplitNode>();
378 }
379
380 [Shortcut("ShaderGraph/Add Node: Tiling and Offset", typeof(MaterialGraphEditWindow), KeyCode.O, ShortcutModifiers.Alt)]
381 static void CreateTilingAndOffset(ShortcutArguments args)
382 {
383 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
384 CreateNode<TilingAndOffsetNode>();
385 }
386
387 [Shortcut("ShaderGraph/Add Node: Time", typeof(MaterialGraphEditWindow), KeyCode.T, ShortcutModifiers.Alt)]
388 static void CreateTime(ShortcutArguments args)
389 {
390 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
391 CreateNode<TimeNode>();
392 }
393
394 [Shortcut("ShaderGraph/Add Node: Position", typeof(MaterialGraphEditWindow), KeyCode.V, ShortcutModifiers.Alt)]
395 static void CreatePosition(ShortcutArguments args)
396 {
397 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
398 CreateNode<PositionNode>();
399 }
400
401 [Shortcut("ShaderGraph/Add Node: Subtract", typeof(MaterialGraphEditWindow), KeyCode.S, ShortcutModifiers.Alt)]
402 static void CreateSubtract(ShortcutArguments args)
403 {
404 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
405 CreateNode<SubtractNode>();
406 }
407
408 [Shortcut("ShaderGraph/Add Node: UV", typeof(MaterialGraphEditWindow), KeyCode.U, ShortcutModifiers.Alt)]
409 static void CreateUV(ShortcutArguments args)
410 {
411 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
412 CreateNode<UVNode>();
413 }
414
415 [Shortcut("ShaderGraph/Add Node: One Minus", typeof(MaterialGraphEditWindow), KeyCode.I, ShortcutModifiers.Alt)]
416 static void CreateOneMinus(ShortcutArguments args)
417 {
418 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
419 CreateNode<OneMinusNode>();
420 }
421
422 [Shortcut("ShaderGraph/Add Node: Branch", typeof(MaterialGraphEditWindow), KeyCode.Y, ShortcutModifiers.Alt)]
423 static void CreateBranch(ShortcutArguments args)
424 {
425 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
426 CreateNode<BranchNode>();
427 }
428
429 [Shortcut("ShaderGraph/Add Node: Divide", typeof(MaterialGraphEditWindow), KeyCode.D, ShortcutModifiers.Alt)]
430 static void CreateDivide(ShortcutArguments args)
431 {
432 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
433 CreateNode<DivideNode>();
434 }
435
436 [Shortcut("ShaderGraph/Add Node: Combine", typeof(MaterialGraphEditWindow), KeyCode.K, ShortcutModifiers.Alt)]
437 static void CreateCombine(ShortcutArguments args)
438 {
439 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
440 CreateNode<CombineNode>();
441 }
442
443 [Shortcut("ShaderGraph/Add Node: Power", typeof(MaterialGraphEditWindow), KeyCode.P, ShortcutModifiers.Alt)]
444 static void CreatePower(ShortcutArguments args)
445 {
446 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
447 CreateNode<PowerNode>();
448 }
449
450 [Shortcut("ShaderGraph/Add Node: Saturate", typeof(MaterialGraphEditWindow), KeyCode.Q, ShortcutModifiers.Alt)]
451 static void CreateSaturate(ShortcutArguments args)
452 {
453 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
454 CreateNode<SaturateNode>();
455 }
456
457 [Shortcut("ShaderGraph/Add Node: Remap", typeof(MaterialGraphEditWindow), KeyCode.R, ShortcutModifiers.Alt)]
458 static void CreateRemap(ShortcutArguments args)
459 {
460 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
461 CreateNode<RemapNode>();
462 }
463
464 [Shortcut("ShaderGraph/Add Node: Normal Vector", typeof(MaterialGraphEditWindow), KeyCode.N, ShortcutModifiers.Alt)]
465 static void CreateNormalVector(ShortcutArguments args)
466 {
467 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
468 CreateNode<NormalVectorNode>();
469 }
470
471 [Shortcut("ShaderGraph/Add Node: Color", typeof(MaterialGraphEditWindow), KeyCode.C, ShortcutModifiers.Alt)]
472 static void CreateColor(ShortcutArguments args)
473 {
474 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
475 CreateNode<ColorNode>();
476 }
477
478 [Shortcut("ShaderGraph/Add Node: Blend", typeof(MaterialGraphEditWindow), KeyCode.B, ShortcutModifiers.Alt)]
479 static void CreateBlend(ShortcutArguments args)
480 {
481 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
482 CreateNode<BlendNode>();
483 }
484
485 [Shortcut("ShaderGraph/Add Node: Step", typeof(MaterialGraphEditWindow), KeyCode.J, ShortcutModifiers.Alt)]
486 static void CreateStep(ShortcutArguments args)
487 {
488 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
489 CreateNode<StepNode>();
490 }
491
492 [Shortcut("ShaderGraph/Add Node: Clamp", typeof(MaterialGraphEditWindow), KeyCode.Equals, ShortcutModifiers.Alt)]
493 static void CreateClamp(ShortcutArguments args)
494 {
495 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
496 CreateNode<ClampNode>();
497 }
498
499 [Shortcut("ShaderGraph/Add Node: Smoothstep", typeof(MaterialGraphEditWindow), KeyCode.BackQuote, ShortcutModifiers.Alt)]
500 static void CreateSmoothstep(ShortcutArguments args)
501 {
502 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
503 CreateNode<SmoothstepNode>();
504 }
505
506 [Shortcut("ShaderGraph/Add Node: Fresnel", typeof(MaterialGraphEditWindow), KeyCode.F, ShortcutModifiers.Alt)]
507 static void CreateFresnel(ShortcutArguments args)
508 {
509 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
510 CreateNode<FresnelNode>();
511 }
512
513 [Shortcut("ShaderGraph/Add Node: Custom Function", typeof(MaterialGraphEditWindow), KeyCode.Semicolon, ShortcutModifiers.Alt)]
514 static void CreateCFN(ShortcutArguments args)
515 {
516 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
517 CreateNode<CustomFunctionNode>();
518 }
519
520 [Shortcut("ShaderGraph/Add Node: Dot Product", typeof(MaterialGraphEditWindow), KeyCode.Period, ShortcutModifiers.Alt)]
521 static void CreateDotProduct(ShortcutArguments args)
522 {
523 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
524 CreateNode<DotProductNode>();
525 }
526
527 [Shortcut("ShaderGraph/Add Node: Normalize", typeof(MaterialGraphEditWindow), KeyCode.Z, ShortcutModifiers.Alt)]
528 static void CreateNormalize(ShortcutArguments args)
529 {
530 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
531 CreateNode<NormalizeNode>();
532 }
533
534 [Shortcut("ShaderGraph/Add Node: Absolute", typeof(MaterialGraphEditWindow), KeyCode.Backslash, ShortcutModifiers.Alt)]
535 static void CreateAbsolute(ShortcutArguments args)
536 {
537 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
538 CreateNode<AbsoluteNode>();
539 }
540
541 [Shortcut("ShaderGraph/Add Node: Negate", typeof(MaterialGraphEditWindow), KeyCode.Minus, ShortcutModifiers.Alt)]
542 static void CreateNegate(ShortcutArguments args)
543 {
544 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
545 CreateNode<NegateNode>();
546 }
547
548 [Shortcut("ShaderGraph/Add Node: Fraction", typeof(MaterialGraphEditWindow), KeyCode.Slash, ShortcutModifiers.Alt)]
549 static void CreateFraction(ShortcutArguments args)
550 {
551 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
552 CreateNode<FractionNode>();
553 }
554
555 [Shortcut("ShaderGraph/Add Node: Swizzle", typeof(MaterialGraphEditWindow), KeyCode.W, ShortcutModifiers.Alt)]
556 static void CreateSwizzle(ShortcutArguments args)
557 {
558 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
559 CreateNode<SwizzleNode>();
560 }
561
562 [Shortcut("ShaderGraph/Add Node: Gradient", typeof(MaterialGraphEditWindow), KeyCode.G, ShortcutModifiers.Alt)]
563 static void CreateGradient(ShortcutArguments args)
564 {
565 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
566 CreateNode<GradientNode>();
567 }
568
569 [Shortcut("ShaderGraph/Add Node: Cross Product", typeof(MaterialGraphEditWindow), KeyCode.H, ShortcutModifiers.Alt)]
570 static void CreateCrossProduct(ShortcutArguments args)
571 {
572 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
573 CreateNode<CrossProductNode>();
574 }
575
576 [Shortcut("ShaderGraph/Add Node: Boolean", typeof(MaterialGraphEditWindow), KeyCode.Alpha0, ShortcutModifiers.Alt)]
577 static void CreateBoolean(ShortcutArguments args)
578 {
579 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
580 CreateNode<BooleanNode>();
581 }
582
583 [Shortcut("ShaderGraph/Add Node: Floor", typeof(MaterialGraphEditWindow), KeyCode.LeftBracket, ShortcutModifiers.Alt)]
584 static void CreateFloor(ShortcutArguments args)
585 {
586 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
587 CreateNode<FloorNode>();
588 }
589
590 [Shortcut("ShaderGraph/Add Node: Ceiling", typeof(MaterialGraphEditWindow), KeyCode.RightBracket, ShortcutModifiers.Alt)]
591 static void CreateCeiling(ShortcutArguments args)
592 {
593 CheckBindings(MethodInfo.GetCurrentMethod().GetCustomAttribute<ShortcutAttribute>().displayName);
594 CreateNode<CeilingNode>();
595 }
596 #endregion
597 }
598}
599
600