summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-23 13:08:43 +0800
committerchai <chaifix@163.com>2020-10-23 13:08:43 +0800
commitb82da95b5181ac8bbae38efb13e950d5e88a4caa (patch)
tree48a6f3269276484bbc7cfc95f0651f40a2176aa1 /Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs80
1 files changed, 80 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs
new file mode 100644
index 00000000..d431cbb8
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs
@@ -0,0 +1,80 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+using UnityEditor;
+
+namespace AmplifyShaderEditor
+{
+ [System.Serializable]
+ [NodeAttributes( "Log", "Master", "Debug node to dump output to log", null, KeyCode.None, false )]
+ public sealed class LogNode : MasterNode
+ {
+ private const string InputAmountStr = "Input amount";
+
+ [SerializeField]
+ private int m_inputCount = 1;
+
+ [SerializeField]
+ private int m_lastInputCount = 1;
+
+ public LogNode() : base() { }
+ public LogNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddMasterPorts();
+ }
+
+ public override void AddMasterPorts()
+ {
+ DeleteAllInputConnections( true );
+ base.AddMasterPorts();
+
+ for ( int i = 0; i < m_inputCount; i++ )
+ {
+ AddInputPort( WirePortDataType.OBJECT, false, i.ToString() );
+ }
+ m_sizeIsDirty = true;
+ }
+
+ public override void DrawProperties()
+ {
+ base.DrawProperties();
+ EditorGUILayout.BeginVertical();
+ {
+ EditorGUILayout.LabelField( InputAmountStr );
+ m_inputCount = EditorGUILayoutIntField( m_inputCount );
+ }
+ EditorGUILayout.EndVertical();
+ if ( m_inputCount != m_lastInputCount )
+ {
+ m_lastInputCount = Mathf.Max( m_inputCount, 1 );
+ AddMasterPorts();
+ }
+ }
+
+ public override void Execute( Shader currentSelected )
+ {
+ string valueDump = "";
+ string valueInstructions = "";
+
+ MasterNodeDataCollector dataCollector = new MasterNodeDataCollector( this );
+ foreach ( InputPort port in InputPorts )
+ {
+ if ( port.IsConnected )
+ {
+ valueInstructions += "Port: " + port.PortId + " Value: " + port.GenerateShaderForOutput( ref dataCollector, port.DataType, false );
+ }
+ }
+ Debug.Log( "Value: " + valueDump );
+ Debug.Log( "Instructions: " + valueInstructions );
+ }
+
+ public override void ReadFromString( ref string[] nodeParams )
+ {
+ base.ReadFromString( ref nodeParams );
+ }
+
+ }
+}