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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyShaderEditor
{
public enum WireStatus
{
Default = 0,
Highlighted,
Selected
}
[Serializable]
public sealed class WireReference
{
private WireStatus m_status = WireStatus.Default;
[SerializeField]
private int m_nodeId = -1;
[SerializeField]
private int m_portId = -1;
[SerializeField]
private WirePortDataType m_dataType = WirePortDataType.FLOAT;
[SerializeField]
private bool m_typeLocked = false;
public WireReference()
{
m_nodeId = -1;
m_portId = -1;
m_dataType = WirePortDataType.FLOAT;
m_typeLocked = false;
m_status = WireStatus.Default;
}
public WireReference( int nodeId, int portId, WirePortDataType dataType, bool typeLocked )
{
m_portId = portId;
m_nodeId = nodeId;
m_dataType = dataType;
m_typeLocked = typeLocked;
m_status = WireStatus.Default;
}
public void Invalidate()
{
m_nodeId = -1;
m_portId = -1;
m_typeLocked = false;
m_status = WireStatus.Default;
}
public void SetReference( int nodeId, int portId, WirePortDataType dataType, bool typeLocked )
{
m_nodeId = nodeId;
m_portId = portId;
m_dataType = dataType;
m_typeLocked = typeLocked;
}
public void SetReference( WirePort port )
{
m_nodeId = port.NodeId;
m_portId = port.PortId;
m_dataType = port.DataType;
}
public bool IsValid
{
get { return ( m_nodeId != -1 && m_portId != -1 ); }
}
public int NodeId
{
get { return m_nodeId; }
}
public int PortId
{
get { return m_portId; }
set { m_portId = value; }
}
public WirePortDataType DataType
{
get { return m_dataType; }
set { m_dataType = value; }
}
public bool TypeLocked
{
get { return m_typeLocked; }
}
public WireStatus WireStatus
{
get { return m_status; }
set { m_status = value; }
}
public override string ToString()
{
string dump = "";
dump += "* Wire Reference *\n";
dump += "NodeId : " + m_nodeId + "\n";
dump += "PortId : " + m_portId + "\n";
dump += "DataType " + m_dataType + "\n"; ;
return dump;
}
public void WriteToString( ref string myString )
{
IOUtils.AddFieldToString( ref myString, "PortId", m_portId );
IOUtils.AddFieldToString( ref myString, "NodeID", m_nodeId );
IOUtils.AddFieldToString( ref myString, "DataType", m_dataType );
IOUtils.AddFieldToString( ref myString, "TypeLocked", m_typeLocked );
}
}
}
|