OutputNode.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using UnityEngine;
  3. namespace AmplifyShaderEditor
  4. {
  5. public class OutputNode : SignalGeneratorNode
  6. {
  7. public static int LOD_SUBSHADER_VERSION = 17200;
  8. [SerializeField]
  9. protected bool m_isMainOutputNode = false;
  10. [SerializeField]
  11. protected int m_lodIndex = -1;
  12. public OutputNode() : base() { }
  13. public OutputNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
  14. public override void ResetNodeData()
  15. {
  16. base.ResetNodeData();
  17. m_graphDepth = -1;
  18. }
  19. public virtual void SetupNodeCategories()
  20. {
  21. ContainerGraph.ResetNodesData();
  22. //int count = m_inputPorts.Count;
  23. //for( int i = 0; i < count; i++ )
  24. //{
  25. // if( m_inputPorts[ i ].IsConnected )
  26. // {
  27. // NodeData nodeData = new NodeData( m_inputPorts[ i ].Category );
  28. // ParentNode node = m_inputPorts[ i ].GetOutputNode();
  29. // node.PropagateNodeData( nodeData, ref collector );
  30. // }
  31. //}
  32. }
  33. public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
  34. {
  35. base.WriteToString( ref nodeInfo, ref connectionsInfo );
  36. IOUtils.AddFieldValueToString( ref nodeInfo, m_isMainOutputNode );
  37. IOUtils.AddFieldValueToString( ref nodeInfo, m_lodIndex );
  38. }
  39. public override void ReadFromString( ref string[] nodeParams )
  40. {
  41. base.ReadFromString( ref nodeParams );
  42. m_isMainOutputNode = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) );
  43. if( UIUtils.CurrentShaderVersion() > LOD_SUBSHADER_VERSION )
  44. {
  45. m_lodIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
  46. }
  47. if( IsLODMainMasterNode && !ContainerGraph.IsDuplicating )
  48. {
  49. ContainerGraph.AssignMasterNode( this, true );
  50. }
  51. }
  52. public override void AfterDuplication()
  53. {
  54. base.AfterDuplication();
  55. m_isMainOutputNode = false;
  56. }
  57. public bool IsMainOutputNode
  58. {
  59. get { return m_isMainOutputNode; }
  60. set
  61. {
  62. if( value != m_isMainOutputNode )
  63. {
  64. m_isMainOutputNode = value;
  65. if( m_isMainOutputNode )
  66. {
  67. GenerateSignalPropagation();
  68. }
  69. else
  70. {
  71. GenerateSignalInibitor();
  72. }
  73. }
  74. }
  75. }
  76. public int LODIndex { get { return m_lodIndex; } set { m_lodIndex = value; } }
  77. public bool IsLODMainMasterNode { get { return m_isMainOutputNode && m_lodIndex == -1; } }
  78. }
  79. }