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.

58 lines
1.6 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System;
  6. namespace AmplifyShaderEditor
  7. {
  8. [Serializable]
  9. [NodeAttributes( "Add", "Math Operators", "Addition of two or more values ( A + B + .. )", null, KeyCode.A )]
  10. public sealed class SimpleAddOpNode : DynamicTypeNode
  11. {
  12. private int m_cachedPropertyId = -1;
  13. protected override void CommonInit( int uniqueId )
  14. {
  15. m_dynamicRestrictions = new WirePortDataType[]
  16. {
  17. WirePortDataType.OBJECT,
  18. WirePortDataType.FLOAT,
  19. WirePortDataType.FLOAT2,
  20. WirePortDataType.FLOAT3,
  21. WirePortDataType.FLOAT4,
  22. WirePortDataType.COLOR,
  23. WirePortDataType.FLOAT3x3,
  24. WirePortDataType.FLOAT4x4,
  25. WirePortDataType.INT
  26. };
  27. base.CommonInit( uniqueId );
  28. m_extensibleInputPorts = true;
  29. m_previewShaderGUID = "9eb150cbc752cbc458a0a37984b9934a";
  30. }
  31. public override void SetPreviewInputs()
  32. {
  33. base.SetPreviewInputs();
  34. if ( m_cachedPropertyId == -1 )
  35. m_cachedPropertyId = Shader.PropertyToID( "_Count" );
  36. PreviewMaterial.SetInt( m_cachedPropertyId, m_inputPorts.Count);
  37. }
  38. public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  39. {
  40. base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
  41. string result = "( " + m_extensibleInputResults[ 0 ];
  42. for ( int i = 1; i < m_extensibleInputResults.Count; i++ )
  43. {
  44. result += " + " + m_extensibleInputResults[ i ];
  45. }
  46. result += " )";
  47. return result;
  48. }
  49. }
  50. }