RelayNode.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using UnityEngine;
  3. namespace AmplifyShaderEditor
  4. {
  5. [Serializable]
  6. [NodeAttributes( "Relay", "Miscellaneous", "Relay" )]
  7. public sealed class RelayNode : ParentNode
  8. {
  9. protected override void CommonInit( int uniqueId )
  10. {
  11. base.CommonInit( uniqueId );
  12. AddInputPort( WirePortDataType.OBJECT, false, Constants.EmptyPortValue );
  13. m_inputPorts[ 0 ].SetFreeForAll();
  14. AddOutputPort( WirePortDataType.OBJECT, Constants.EmptyPortValue );
  15. m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929";
  16. }
  17. public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
  18. {
  19. base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
  20. m_inputPorts[ 0 ].MatchPortToConnection();
  21. m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
  22. }
  23. public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
  24. {
  25. base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
  26. m_inputPorts[ 0 ].MatchPortToConnection();
  27. m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
  28. }
  29. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  30. {
  31. base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
  32. return m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar );
  33. }
  34. }
  35. }