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/Nodes/NodeUsageRegister.cs | 203 --------------------- 1 file changed, 203 deletions(-) delete mode 100644 Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs') diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs deleted file mode 100644 index 944ce812..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] public class UsageListSamplerNodes : NodeUsageRegister { } - [Serializable] public class UsageListFloatIntNodes : NodeUsageRegister { } - [Serializable] public class UsageListTexturePropertyNodes : NodeUsageRegister { } - [Serializable] public class UsageListTextureArrayNodes : NodeUsageRegister { } - [Serializable] public class UsageListPropertyNodes : NodeUsageRegister { } - [Serializable] public class UsageListScreenColorNodes : NodeUsageRegister { } - [Serializable] public class UsageListRegisterLocalVarNodes : NodeUsageRegister { } - [Serializable] public class UsageListFunctionInputNodes : NodeUsageRegister { } - [Serializable] public class UsageListFunctionNodes : NodeUsageRegister { } - [Serializable] public class UsageListFunctionOutputNodes : NodeUsageRegister { } - [Serializable] public class UsageListFunctionSwitchNodes : NodeUsageRegister { } - [Serializable] public class UsageListFunctionSwitchCopyNodes : NodeUsageRegister { } - [Serializable] public class UsageListTemplateMultiPassMasterNodes : NodeUsageRegister { } - [Serializable] public class UsageListCustomExpressionsOnFunctionMode : NodeUsageRegister { } - [Serializable] public class UsageListGlobalArrayNodes : NodeUsageRegister { } - [Serializable] public class UsageListStaticSwitchNodes : NodeUsageRegister { } - - [Serializable] - public class NodeUsageRegister where T : ParentNode - { - public delegate void ReorderEvent(); - public event ReorderEvent OnReorderEventComplete; - - [SerializeField] - public bool ReorderOnChange = false; - - // Sampler Nodes registry - [SerializeField] - private List m_nodes; - - [SerializeField] - private string[] m_nodesArr; - - [SerializeField] - private int[] m_nodeIDs; - - [SerializeField] - ParentGraph m_containerGraph; - - public NodeUsageRegister() - { - m_nodesArr = new string[ 0 ]; - m_nodeIDs = new int[ 0 ]; - m_nodes = new List(); - } - - public void Destroy() - { - m_nodes.Clear(); - m_nodes = null; - m_nodesArr = null; - m_nodeIDs = null; - } - - public void Clear() - { - m_nodes.Clear(); - } - - public int AddNode( T node ) - { - if( node == null ) - return -1; - - if( !m_nodes.Contains( node ) ) - { - if( m_containerGraph != null ) - { - Undo.RegisterCompleteObjectUndo( m_containerGraph.ParentWindow, Constants.UndoRegisterNodeId ); - Undo.RegisterCompleteObjectUndo( m_containerGraph, Constants.UndoRegisterNodeId ); - } - m_nodes.Add( node ); - ReorderNodes(); - UpdateNodeArr(); - return m_nodes.Count - 1; - } - else if( node.UniqueId > -1 ) - { - UpdateNodeArr(); - } - - return -1; - } - - public bool HasNode( int uniqueId ) - { - return m_nodes.FindIndex( x => x.UniqueId == uniqueId ) > -1 ? true : false; - } - - public void RemoveNode( T node ) - { - if( node == null ) - return; - - if( m_nodes.Contains( node ) ) - { - if( m_containerGraph != null ) - { - Undo.RegisterCompleteObjectUndo( m_containerGraph.ParentWindow, Constants.UndoUnregisterNodeId ); - Undo.RegisterCompleteObjectUndo( m_containerGraph, Constants.UndoUnregisterNodeId ); - } - - m_nodes.Remove( node ); - ReorderNodes(); - UpdateNodeArr(); - } - } - - public void ReorderNodes() - { - if( ReorderOnChange ) - { - m_nodes.Sort( ( x, y ) => ( x.DataToArray.CompareTo( y.DataToArray ) ) ); - if( OnReorderEventComplete != null ) - { - OnReorderEventComplete(); - } - } - } - - public void UpdateNodeArr() - { - int nodeCount = m_nodes.Count; - if( nodeCount != m_nodesArr.Length ) - { - m_nodesArr = new string[ nodeCount ]; - m_nodeIDs = new int[ nodeCount ]; - } - - for( int i = 0; i < nodeCount; i++ ) - { - m_nodesArr[ i ] = m_nodes[ i ].DataToArray; - m_nodeIDs[ i ] = m_nodes[ i ].UniqueId; - } - } - - public T GetNode( int idx ) - { - if( idx > -1 && idx < m_nodes.Count ) - { - return m_nodes[ idx ]; - } - return null; - } - - public T GetNodeByUniqueId( int uniqueId ) - { - return m_nodes.Find( x => x.UniqueId == uniqueId ); - } - - public T GetNodeByDataToArray( string data ) - { - return m_nodes.Find( x => x.DataToArray.Equals( data )); - } - - public int GetNodeRegisterIdx( int uniqueId ) - { - return m_nodes.FindIndex( x => x.UniqueId == uniqueId ); - } - - public void UpdateDataOnNode( int uniqueId, string data ) - { - if( ReorderOnChange ) - { - ReorderNodes(); - UpdateNodeArr(); - } - else - { - int index = m_nodes.FindIndex( x => x.UniqueId == uniqueId ); - if( index > -1 ) - { - m_nodesArr[ index ] = data; - m_nodeIDs[ index ] = uniqueId; - } - } - } - - public void Dump() - { - string data = string.Empty; - - for( int i = 0; i < m_nodesArr.Length; i++ ) - { - data += m_nodesArr[ i ] + " " + m_nodeIDs[ i ] + '\n'; - } - Debug.Log( data ); - } - - public string[] NodesArr { get { return m_nodesArr; } } - public int[] NodeIds { get { return m_nodeIDs; } } - public List NodesList { get { return m_nodes; } } - public int Count { get { return m_nodes.Count; } } - public ParentGraph ContainerGraph { get { return m_containerGraph; } set { m_containerGraph = value; } } - } -} -- cgit v1.1-26-g67d0