CreateShaderSubGraph.cs 986 B

1234567891011121314151617181920212223242526
  1. using System.IO;
  2. using UnityEditor.ProjectWindowCallback;
  3. namespace UnityEditor.ShaderGraph
  4. {
  5. class CreateShaderSubGraph : EndNameEditAction
  6. {
  7. [MenuItem("Assets/Create/Shader/Sub Graph", false, 208)]
  8. public static void CreateMaterialSubGraph()
  9. {
  10. ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateShaderSubGraph>(),
  11. string.Format("New Shader Sub Graph.{0}", ShaderSubGraphImporter.Extension), null, null);
  12. }
  13. public override void Action(int instanceId, string pathName, string resourceFile)
  14. {
  15. var graph = new GraphData { isSubGraph = true };
  16. var outputNode = new SubGraphOutputNode();
  17. graph.AddNode(outputNode);
  18. outputNode.AddSlot(ConcreteSlotValueType.Vector4);
  19. graph.path = "Sub Graphs";
  20. FileUtilities.WriteShaderGraphToDisk(pathName, graph);
  21. AssetDatabase.Refresh();
  22. }
  23. }
  24. }