1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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 );
}
}
}
|