mathe/Library/PackageCache/com.unity.shadergraph@14.0.8/Editor/Data/Graphs/GraphConcretization.cs
2024-09-20 20:30:10 +02:00

40 lines
1.2 KiB
C#

using System.Linq;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
sealed partial class GraphData : ISerializationCallbackReceiver
{
public static class GraphConcretization
{
public static void ConcretizeNode(AbstractMaterialNode node)
{
node.Concretize();
}
public static void ConcretizeProperties(GraphData graph)
{
var propertyNodes = graph.GetNodes<PropertyNode>().Where(n => !graph.m_Properties.Any(p => p == n.property)).ToArray();
foreach (var pNode in propertyNodes)
graph.ReplacePropertyNodeWithConcreteNodeNoValidate(pNode);
}
public static void ConcretizeGraph(GraphData graph)
{
graph.graphIsConcretizing = true;
try
{
ConcretizeProperties(graph);
GraphDataUtils.ApplyActionLeafFirst(graph, ConcretizeNode);
}
catch (System.Exception e)
{
graph.graphIsConcretizing = false;
throw e;
}
graph.graphIsConcretizing = false;
}
}
}
}