UVCoordsParentNode.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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( "[Old]Texture Coordinates", "Surface Data", "Texture UV coordinates set", null, KeyCode.U, false )]
  10. // public sealed class UVCoordsParentNode : ParentNode
  11. // {
  12. // private const string TilingStr = "Tiling";
  13. // [SerializeField]
  14. // private int m_textureCoordChannel = 0;
  15. // [SerializeField]
  16. // private int m_textureCoordSet = 0;
  17. // [SerializeField]
  18. // private Vector2 m_tiling = new Vector2( 1, 1 );
  19. // protected override void CommonInit( int uniqueId )
  20. // {
  21. // base.CommonInit( uniqueId );
  22. // AddOutputVectorPorts( WirePortDataType.FLOAT2, Constants.EmptyPortValue );
  23. // m_textLabelWidth = 75;
  24. // }
  25. // public override void DrawProperties()
  26. // {
  27. // base.DrawProperties();
  28. // int newChannel = EditorGUILayoutIntPopup( Constants.AvailableUVChannelLabel, m_textureCoordChannel, Constants.AvailableUVChannelsStr, Constants.AvailableUVChannels );
  29. // if ( newChannel != m_textureCoordChannel )
  30. // {
  31. // if ( UIUtils.IsChannelAvailable( newChannel ) )
  32. // {
  33. // UIUtils.ShowMessage( "Attempting to use an unoccupied used texture channel" );
  34. // }
  35. // else
  36. // {
  37. // m_textureCoordChannel = newChannel;
  38. // }
  39. // }
  40. // else if ( m_textureCoordChannel > -1 && UIUtils.IsChannelAvailable( m_textureCoordChannel ) )
  41. // {
  42. // UIUtils.ShowMessage( "Texture Channel " + m_textureCoordChannel + " is unavailable for TextureCoordinate node" );
  43. // m_textureCoordChannel = -1;
  44. // }
  45. // m_textureCoordSet = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets );
  46. // m_tiling = EditorGUILayoutVector2Field( TilingStr, m_tiling );
  47. // }
  48. // public override void Draw( DrawInfo drawInfo )
  49. // {
  50. // base.Draw( drawInfo );
  51. // if ( m_isVisible )
  52. // {
  53. // m_propertyDrawPos.x = m_globalPosition.x + Constants.FLOAT_WIDTH_SPACING;
  54. // m_propertyDrawPos.y = m_outputPorts[ 1 ].Position.y;
  55. // m_propertyDrawPos.width = 2.7f * drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE;
  56. // m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE;
  57. // m_propertyDrawPos.y = m_outputPorts[ 1 ].Position.y;
  58. // UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_tiling.x );
  59. // m_propertyDrawPos.y = m_outputPorts[ 2 ].Position.y;
  60. // UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_tiling.y );
  61. // }
  62. // }
  63. // public override void ReadFromString( ref string[] nodeParams )
  64. // {
  65. // base.ReadFromString( ref nodeParams );
  66. // m_textureCoordChannel = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
  67. // m_tiling.x = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
  68. // m_tiling.y = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
  69. // }
  70. // public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
  71. // {
  72. // base.WriteToString( ref nodeInfo, ref connectionsInfo );
  73. // IOUtils.AddFieldValueToString( ref nodeInfo, m_textureCoordChannel );
  74. // IOUtils.AddFieldValueToString( ref nodeInfo, m_tiling.x );
  75. // IOUtils.AddFieldValueToString( ref nodeInfo, m_tiling.y );
  76. // }
  77. // public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
  78. // {
  79. // string uvChannelDeclaration = IOUtils.GetUVChannelDeclaration( UIUtils.GetChannelName( m_textureCoordChannel ), m_textureCoordChannel, m_textureCoordSet );
  80. // dataCollector.AddToInput( UniqueId, uvChannelDeclaration, true );
  81. // if ( dataCollector.GetChannelUsage( m_textureCoordChannel ) != TextureChannelUsage.Used )
  82. // dataCollector.SetChannelUsage( m_textureCoordChannel, TextureChannelUsage.Required );
  83. // string uvTileStr = string.Empty;
  84. // switch ( outputId )
  85. // {
  86. // case 0: { uvTileStr = "float2( " + m_tiling.x + " , " + m_tiling.y + " )"; } break;
  87. // case 1: { uvTileStr = m_tiling.x.ToString(); } break;
  88. // case 2: { uvTileStr = m_tiling.y.ToString(); } break;
  89. // }
  90. // string uvChannelName = IOUtils.GetUVChannelName( UIUtils.GetChannelName( m_textureCoordChannel ), m_textureCoordSet );
  91. // return ( uvTileStr + "*" + GetOutputVectorItem( 0, outputId, Constants.InputVarStr + "." + uvChannelName ) );
  92. // }
  93. // }
  94. //}