From b82da95b5181ac8bbae38efb13e950d5e88a4caa Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 23 Oct 2020 13:08:43 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8amplify=20shader=20editor=E5=88=B0th?= =?UTF-8?q?ird=20party=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Plugins/Editor/Wires/WireReference.cs | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Wires/WireReference.cs (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Wires/WireReference.cs') diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Wires/WireReference.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Wires/WireReference.cs new file mode 100644 index 00000000..fb2b3472 --- /dev/null +++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Wires/WireReference.cs @@ -0,0 +1,126 @@ +// Amplify Shader Editor - Visual Shader Editing Tool +// Copyright (c) Amplify Creations, Lda + +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 ); + } + } +} -- cgit v1.1-26-g67d0