ConstVecShaderVariable.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. using System;
  5. namespace AmplifyShaderEditor
  6. {
  7. [Serializable]
  8. public class ConstVecShaderVariable : ShaderVariablesNode
  9. {
  10. [SerializeField]
  11. protected string m_value;
  12. protected override void CommonInit( int uniqueId )
  13. {
  14. base.CommonInit( uniqueId );
  15. ChangeOutputProperties( 0, " ", WirePortDataType.FLOAT4 );
  16. AddOutputPort( WirePortDataType.FLOAT, "0" );
  17. AddOutputPort( WirePortDataType.FLOAT, "1" );
  18. AddOutputPort( WirePortDataType.FLOAT, "2" );
  19. AddOutputPort( WirePortDataType.FLOAT, "3" );
  20. }
  21. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  22. {
  23. base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
  24. switch ( outputId )
  25. {
  26. case 0: return m_value;
  27. case 1: return ( m_value + ".x" );
  28. case 2: return ( m_value + ".y" );
  29. case 3: return ( m_value + ".z" );
  30. case 4: return ( m_value + ".w" );
  31. }
  32. UIUtils.ShowMessage( UniqueId, "ConstVecShaderVariable generating empty code", MessageSeverity.Warning );
  33. return string.Empty;
  34. }
  35. }
  36. }