blob: 8bd85dc498cde91b00f20547ee40e62367966e4f (
plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace AmplifyShaderEditor
{
[Serializable]
public class ReordenatorNode : PropertyNode
{
[SerializeField]
private List<PropertyNode> m_propertyList;
[SerializeField]
private string m_headerTitle = string.Empty;
[SerializeField]
private bool m_isInside;
public ReordenatorNode() : base()
{
}
public void Init( string entryName, string entryInspectorName, List<PropertyNode> list, bool register = true )
{
m_propertyName = entryName;
m_propertyInspectorName = entryInspectorName;
m_propertyList = list;
if( register )
UIUtils.RegisterPropertyNode( this );
}
public override void Destroy()
{
base.Destroy();
m_propertyList.Clear();
m_propertyList = null;
UIUtils.UnregisterPropertyNode( this );
}
//public List<ParentNode> PropertyList
//{
// get { return m_propertyList; }
//}
public int PropertyListCount
{
get { if ( m_propertyList != null ) return m_propertyList.Count; else return -1; }
}
public string HeaderTitle { get { return m_headerTitle; } set { m_headerTitle = value; } }
public bool HasTitle { get { return !string.IsNullOrEmpty( m_headerTitle ); } }
public bool IsInside { get { return m_isInside; } set { m_isInside = value; } }
public int RecursiveSetOrderOffset( int offset, bool lockit, int order = -1 )
{
//Debug.Log( Locked + " " + PropertyName );
if ( Locked )
return offset;
if( order > -1 )
OrderIndex = order;
int currentOffset = offset;
if( m_propertyList != null )
m_propertyList.Sort( ( x, y ) => { return ( x as PropertyNode ).OrderIndex.CompareTo( ( y as PropertyNode ).OrderIndex ); } );
OrderIndexOffset = currentOffset - RawOrderIndex;
currentOffset++;
if ( m_propertyList != null )
for ( int i = 0; i < m_propertyList.Count; i++ )
{
ReordenatorNode rnode = m_propertyList[ i ] as ReordenatorNode;
if ( rnode != null )
{
currentOffset = rnode.RecursiveSetOrderOffset( currentOffset, false );
}
else
{
PropertyNode pnode = m_propertyList[ i ] as PropertyNode;
{
pnode.OrderIndexOffset = currentOffset - pnode.RawOrderIndex;// + ( HasTitle ? 1 : 0 );
}
currentOffset++;
}
}
if ( lockit )
Locked = true;
return currentOffset;
}
public int RecursiveCount()
{
int amount = 0;
if ( HasTitle )
amount += 1;
for ( int i = 0; i < m_propertyList.Count; i++ )
{
if ( ( m_propertyList[ i ] is ReordenatorNode ) )
amount += ( m_propertyList[ i ] as ReordenatorNode ).RecursiveCount();
else
amount +=1;
}
return amount;
}
public void RecursiveLog()
{
Debug.LogWarning( OrderIndex+" HEADER "+ PropertyName );
for( int i = 0; i < m_propertyList.Count; i++ )
{
if( ( m_propertyList[ i ] is ReordenatorNode ) )
( m_propertyList[ i ] as ReordenatorNode ).RecursiveLog();
else
Debug.Log( ( m_propertyList[ i ] as PropertyNode ).OrderIndex+" "+( m_propertyList[ i ] as PropertyNode).PropertyName );
}
}
public bool Locked = false;
public void RecursiveClear()
{
Locked = false;
if( m_propertyList != null)
for ( int i = 0; i < m_propertyList.Count; i++ )
{
ReordenatorNode renode = ( m_propertyList[ i ] as ReordenatorNode );
if ( renode != null )
{
renode.RecursiveClear();
}
}
}
public bool RecursiveConnectedProperties()
{
bool connected = false;
if ( m_propertyList != null )
{
for ( int i = 0; i < m_propertyList.Count; i++ )
{
ReordenatorNode renode = ( m_propertyList[ i ] as ReordenatorNode );
if ( renode != null )
{
bool temp = renode.RecursiveConnectedProperties();
if( temp )
connected = true;
} else
{
if ( ( m_propertyList[ i ] as PropertyNode ).IsConnected )
connected = true;
}
}
}
return connected;
}
}
}
|