A game about forced loneliness, made by TACStudios
at master 40 lines 1.4 kB view raw
1using System.Linq; 2using UnityEngine; 3 4namespace UnityEditor.ShaderGraph 5{ 6 sealed partial class GraphData : ISerializationCallbackReceiver 7 { 8 public static class GraphConcretization 9 { 10 public static void ConcretizeNode(AbstractMaterialNode node) 11 { 12 node.Concretize(); 13 } 14 15 public static void ConcretizeProperties(GraphData graph) 16 { 17 // get all property nodes whose property doesn't exist? 18 var propertyNodes = graph.GetNodes<PropertyNode>().Where(n => !graph.m_Properties.Any(p => p.value == n.property || n.property != null && p.value.objectId == n.property.objectId)).ToArray(); 19 foreach (var pNode in propertyNodes) 20 graph.ReplacePropertyNodeWithConcreteNodeNoValidate(pNode); 21 } 22 23 public static void ConcretizeGraph(GraphData graph) 24 { 25 graph.graphIsConcretizing = true; 26 try 27 { 28 ConcretizeProperties(graph); 29 GraphDataUtils.ApplyActionLeafFirst(graph, ConcretizeNode); 30 } 31 catch (System.Exception e) 32 { 33 graph.graphIsConcretizing = false; 34 throw e; 35 } 36 graph.graphIsConcretizing = false; 37 } 38 } 39 } 40}