暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ShaderGraphShortcuts.cs 26KB

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