@@ -31,45 +31,36 @@ private void SetupRootNodeSettings()
31
31
32
32
public override void FetchData ( )
33
33
{
34
- if ( AddCurvesPopup . selection == null )
35
- return ;
36
-
37
- AnimationWindowSelectionItem [ ] selectionItems = AddCurvesPopup . selection . ToArray ( ) ;
38
- if ( selectionItems . Length > 1 )
39
- {
40
- m_RootItem = new AddCurvesPopupObjectNode ( null , "" , "" ) ;
41
- }
42
-
43
- foreach ( AnimationWindowSelectionItem item in selectionItems )
34
+ if ( AddCurvesPopup . s_State . selection . canAddCurves )
44
35
{
45
- if ( ! item . canAddCurves )
46
- continue ;
36
+ GameObject rootGameObject = AddCurvesPopup . s_State . activeRootGameObject ;
37
+ ScriptableObject scriptableObject = AddCurvesPopup . s_State . activeScriptableObject ;
47
38
48
- if ( item . rootGameObject != null )
39
+ if ( rootGameObject != null )
49
40
{
50
- AddGameObjectToHierarchy ( item . rootGameObject , item , m_RootItem ) ;
41
+ AddGameObjectToHierarchy ( rootGameObject , rootGameObject , AddCurvesPopup . s_State . activeAnimationClip , m_RootItem ) ;
51
42
}
52
- else if ( item . scriptableObject != null )
43
+ else if ( scriptableObject != null )
53
44
{
54
- AddScriptableObjectToHierarchy ( item . scriptableObject , item , m_RootItem ) ;
45
+ AddScriptableObjectToHierarchy ( scriptableObject , AddCurvesPopup . s_State . activeAnimationClip , m_RootItem ) ;
55
46
}
56
47
}
57
48
58
49
SetupRootNodeSettings ( ) ;
59
50
m_NeedRefreshRows = true ;
60
51
}
61
52
62
- private TreeViewItem AddGameObjectToHierarchy ( GameObject gameObject , AnimationWindowSelectionItem selectionItem , TreeViewItem parent )
53
+ private TreeViewItem AddGameObjectToHierarchy ( GameObject gameObject , GameObject rootGameObject , AnimationClip animationClip , TreeViewItem parent )
63
54
{
64
- string path = AnimationUtility . CalculateTransformPath ( gameObject . transform , selectionItem . rootGameObject . transform ) ;
55
+ string path = AnimationUtility . CalculateTransformPath ( gameObject . transform , rootGameObject . transform ) ;
65
56
TreeViewItem node = new AddCurvesPopupGameObjectNode ( gameObject , parent , gameObject . name ) ;
66
57
List < TreeViewItem > childNodes = new List < TreeViewItem > ( ) ;
67
58
68
59
if ( m_RootItem == null )
69
60
m_RootItem = node ;
70
61
71
62
// Iterate over all animatable objects
72
- EditorCurveBinding [ ] allCurveBindings = AnimationUtility . GetAnimatableBindings ( gameObject , selectionItem . rootGameObject ) ;
63
+ EditorCurveBinding [ ] allCurveBindings = AnimationUtility . GetAnimatableBindings ( gameObject , rootGameObject ) ;
73
64
List < EditorCurveBinding > singleObjectBindings = new List < EditorCurveBinding > ( ) ;
74
65
for ( int i = 0 ; i < allCurveBindings . Length ; i ++ )
75
66
{
@@ -83,7 +74,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
83
74
// Don't show for the root go
84
75
if ( curveBinding . path != "" )
85
76
{
86
- TreeViewItem newNode = CreateNode ( selectionItem , singleObjectBindings . ToArray ( ) , node ) ;
77
+ TreeViewItem newNode = CreateNode ( singleObjectBindings . ToArray ( ) , node ) ;
87
78
if ( newNode != null )
88
79
childNodes . Add ( newNode ) ;
89
80
singleObjectBindings . Clear ( ) ;
@@ -104,7 +95,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
104
95
isLastItemOnThisGroup = ( allCurveBindings [ i + 1 ] . type != curveBinding . type ) ;
105
96
106
97
// Let's not add those that already have a existing curve.
107
- if ( AnimationWindowUtility . IsCurveCreated ( selectionItem . animationClip , curveBinding ) )
98
+ if ( AnimationWindowUtility . IsCurveCreated ( animationClip , curveBinding ) )
108
99
singleObjectBindings . Remove ( curveBinding ) ;
109
100
110
101
// Remove animator enabled property which shouldn't be animated.
@@ -113,7 +104,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
113
104
114
105
if ( ( isLastItemOverall || isLastItemOnThisGroup ) && singleObjectBindings . Count > 0 )
115
106
{
116
- childNodes . Add ( AddAnimatableObjectToHierarchy ( selectionItem , singleObjectBindings . ToArray ( ) , node , path ) ) ;
107
+ childNodes . Add ( AddAnimatableObjectToHierarchy ( singleObjectBindings . ToArray ( ) , node , path ) ) ;
117
108
singleObjectBindings . Clear ( ) ;
118
109
}
119
110
}
@@ -125,7 +116,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
125
116
for ( int i = 0 ; i < gameObject . transform . childCount ; i ++ )
126
117
{
127
118
Transform childTransform = gameObject . transform . GetChild ( i ) ;
128
- TreeViewItem childNode = AddGameObjectToHierarchy ( childTransform . gameObject , selectionItem , node ) ;
119
+ TreeViewItem childNode = AddGameObjectToHierarchy ( childTransform . gameObject , rootGameObject , animationClip , node ) ;
129
120
if ( childNode != null )
130
121
childNodes . Add ( childNode ) ;
131
122
}
@@ -135,14 +126,14 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
135
126
return node ;
136
127
}
137
128
138
- private TreeViewItem AddScriptableObjectToHierarchy ( ScriptableObject scriptableObject , AnimationWindowSelectionItem selectionItem , TreeViewItem parent )
129
+ private TreeViewItem AddScriptableObjectToHierarchy ( ScriptableObject scriptableObject , AnimationClip clip , TreeViewItem parent )
139
130
{
140
131
EditorCurveBinding [ ] allCurveBindings = AnimationUtility . GetScriptableObjectAnimatableBindings ( scriptableObject ) ;
141
- EditorCurveBinding [ ] availableBindings = allCurveBindings . Where ( c => ! AnimationWindowUtility . IsCurveCreated ( selectionItem . animationClip , c ) ) . ToArray ( ) ;
132
+ EditorCurveBinding [ ] availableBindings = allCurveBindings . Where ( c => ! AnimationWindowUtility . IsCurveCreated ( clip , c ) ) . ToArray ( ) ;
142
133
143
134
TreeViewItem node = null ;
144
135
if ( availableBindings . Length > 0 )
145
- node = AddAnimatableObjectToHierarchy ( selectionItem , availableBindings , parent , "" ) ;
136
+ node = AddAnimatableObjectToHierarchy ( availableBindings , parent , "" ) ;
146
137
else
147
138
node = new AddCurvesPopupObjectNode ( parent , "" , scriptableObject . name ) ;
148
139
@@ -152,36 +143,36 @@ private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableO
152
143
return node ;
153
144
}
154
145
155
- static string GetClassName ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding binding )
146
+ static string GetClassName ( EditorCurveBinding binding )
156
147
{
157
- if ( selectionItem . rootGameObject != null )
148
+ if ( AddCurvesPopup . s_State . activeRootGameObject != null )
158
149
{
159
- Object target = AnimationUtility . GetAnimatedObject ( selectionItem . rootGameObject , binding ) ;
150
+ Object target = AnimationUtility . GetAnimatedObject ( AddCurvesPopup . s_State . activeRootGameObject , binding ) ;
160
151
if ( target )
161
152
return ObjectNames . GetInspectorTitle ( target ) ;
162
153
}
163
154
164
155
return binding . type . Name ;
165
156
}
166
157
167
- static Texture2D GetIcon ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding binding )
158
+ static Texture2D GetIcon ( EditorCurveBinding binding )
168
159
{
169
- if ( selectionItem . rootGameObject != null )
160
+ if ( AddCurvesPopup . s_State . activeRootGameObject != null )
170
161
{
171
- return AssetPreview . GetMiniThumbnail ( AnimationUtility . GetAnimatedObject ( selectionItem . rootGameObject , binding ) ) ;
162
+ return AssetPreview . GetMiniThumbnail ( AnimationUtility . GetAnimatedObject ( AddCurvesPopup . s_State . activeRootGameObject , binding ) ) ;
172
163
}
173
- else if ( selectionItem . scriptableObject != null )
164
+ else if ( AddCurvesPopup . s_State . activeScriptableObject != null )
174
165
{
175
- return AssetPreview . GetMiniThumbnail ( selectionItem . scriptableObject ) ;
166
+ return AssetPreview . GetMiniThumbnail ( AddCurvesPopup . s_State . activeScriptableObject ) ;
176
167
}
177
168
178
169
return null ;
179
170
}
180
171
181
- private TreeViewItem AddAnimatableObjectToHierarchy ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode , string path )
172
+ private TreeViewItem AddAnimatableObjectToHierarchy ( EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode , string path )
182
173
{
183
- TreeViewItem node = new AddCurvesPopupObjectNode ( parentNode , path , GetClassName ( selectionItem , curveBindings [ 0 ] ) ) ;
184
- node . icon = GetIcon ( selectionItem , curveBindings [ 0 ] ) ;
174
+ TreeViewItem node = new AddCurvesPopupObjectNode ( parentNode , path , GetClassName ( curveBindings [ 0 ] ) ) ;
175
+ node . icon = GetIcon ( curveBindings [ 0 ] ) ;
185
176
186
177
List < TreeViewItem > childNodes = new List < TreeViewItem > ( ) ;
187
178
List < EditorCurveBinding > singlePropertyBindings = new List < EditorCurveBinding > ( ) ;
@@ -195,7 +186,7 @@ private TreeViewItem AddAnimatableObjectToHierarchy(AnimationWindowSelectionItem
195
186
// We expect curveBindings to come sorted by propertyname
196
187
if ( i == curveBindings . Length - 1 || AnimationWindowUtility . GetPropertyGroupName ( curveBindings [ i + 1 ] . propertyName ) != AnimationWindowUtility . GetPropertyGroupName ( curveBinding . propertyName ) )
197
188
{
198
- TreeViewItem newNode = CreateNode ( selectionItem , singlePropertyBindings . ToArray ( ) , node ) ;
189
+ TreeViewItem newNode = CreateNode ( singlePropertyBindings . ToArray ( ) , node ) ;
199
190
if ( newNode != null )
200
191
childNodes . Add ( newNode ) ;
201
192
singlePropertyBindings . Clear ( ) ;
@@ -208,9 +199,9 @@ private TreeViewItem AddAnimatableObjectToHierarchy(AnimationWindowSelectionItem
208
199
return node ;
209
200
}
210
201
211
- private TreeViewItem CreateNode ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode )
202
+ private TreeViewItem CreateNode ( EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode )
212
203
{
213
- var node = new AddCurvesPopupPropertyNode ( parentNode , selectionItem , curveBindings ) ;
204
+ var node = new AddCurvesPopupPropertyNode ( parentNode , curveBindings ) ;
214
205
215
206
// For RectTransform.position we only want .z
216
207
if ( AnimationWindowUtility . IsRectTransformPosition ( node . curveBindings [ 0 ] ) )
@@ -244,13 +235,11 @@ public AddCurvesPopupObjectNode(TreeViewItem parent, string path, string classNa
244
235
245
236
internal class AddCurvesPopupPropertyNode : TreeViewItem
246
237
{
247
- public AnimationWindowSelectionItem selectionItem ;
248
238
public EditorCurveBinding [ ] curveBindings ;
249
239
250
- public AddCurvesPopupPropertyNode ( TreeViewItem parent , AnimationWindowSelectionItem selectionItem , EditorCurveBinding [ ] curveBindings )
240
+ public AddCurvesPopupPropertyNode ( TreeViewItem parent , EditorCurveBinding [ ] curveBindings )
251
241
: base ( curveBindings [ 0 ] . GetHashCode ( ) , parent . depth + 1 , parent , AnimationWindowUtility . NicifyPropertyGroupName ( curveBindings [ 0 ] . type , AnimationWindowUtility . GetPropertyGroupName ( curveBindings [ 0 ] . propertyName ) ) )
252
242
{
253
- this . selectionItem = selectionItem ;
254
243
this . curveBindings = curveBindings ;
255
244
}
256
245
0 commit comments