Editor/ShaderGraphPlus/ProjectConverter/Node Core/ResultNodeConvert.cs

An editor ProjectConverter class that converts an old ShaderGraph Result node to a new Result node type used by ShaderGraphPlus. It copies identifier, position and several default material property fields from the old node to the new node and returns the new node wrapped in a list.

using VanillaGraph = Editor.ShaderGraph;
using VanillaNodes = Editor.ShaderGraph.Nodes;
using ShaderGraphBaseNode = Editor.ShaderGraph.BaseNode;

namespace ShaderGraphPlus.Internal;

internal class ResultNodeConvert : BaseNodeConvert
{
	public override Type NodeTypeToConvert => typeof( VanillaGraph.Result );

	public override IEnumerable<BaseNodePlus> Convert( ProjectConverter converter, ShaderGraphBaseNode oldNode )
	{
		var newNodes = new List<BaseNodePlus>();
		var oldResultNode = oldNode as VanillaGraph.Result;

		//SGPLog.Info( "Convert result node" );

		var newNode = new Result();
		newNode.Identifier = oldNode.Identifier;
		newNode.Position = oldNode.Position;
		newNode.DefaultAmbientOcclusion = oldResultNode.DefaultAmbientOcclusion;
		newNode.DefaultMetalness = oldResultNode.DefaultMetalness;
		newNode.DefaultOpacity = oldResultNode.DefaultOpacity;
		newNode.DefaultRoughness = oldResultNode.DefaultRoughness;


		newNodes.Add( newNode );

		return newNodes;
	}
}