You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.6 KiB

  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. AddOutputPort( WirePortDataType.OBJECT, Constants.EmptyPortValue );
  14. m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929";
  15. }
  16. public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true )
  17. {
  18. base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode );
  19. m_inputPorts[ 0 ].MatchPortToConnection();
  20. m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
  21. }
  22. public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type )
  23. {
  24. base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type );
  25. m_inputPorts[ 0 ].MatchPortToConnection();
  26. m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false );
  27. }
  28. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  29. {
  30. base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
  31. return m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar );
  32. }
  33. }
  34. }