@@ -31,45 +31,36 @@ private void SetupRootNodeSettings()
3131
3232 public override void FetchData ( )
3333 {
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 )
4435 {
45- if ( ! item . canAddCurves )
46- continue ;
36+ GameObject rootGameObject = AddCurvesPopup . s_State . activeRootGameObject ;
37+ ScriptableObject scriptableObject = AddCurvesPopup . s_State . activeScriptableObject ;
4738
48- if ( item . rootGameObject != null )
39+ if ( rootGameObject != null )
4940 {
50- AddGameObjectToHierarchy ( item . rootGameObject , item , m_RootItem ) ;
41+ AddGameObjectToHierarchy ( rootGameObject , rootGameObject , AddCurvesPopup . s_State . activeAnimationClip , m_RootItem ) ;
5142 }
52- else if ( item . scriptableObject != null )
43+ else if ( scriptableObject != null )
5344 {
54- AddScriptableObjectToHierarchy ( item . scriptableObject , item , m_RootItem ) ;
45+ AddScriptableObjectToHierarchy ( scriptableObject , AddCurvesPopup . s_State . activeAnimationClip , m_RootItem ) ;
5546 }
5647 }
5748
5849 SetupRootNodeSettings ( ) ;
5950 m_NeedRefreshRows = true ;
6051 }
6152
62- private TreeViewItem AddGameObjectToHierarchy ( GameObject gameObject , AnimationWindowSelectionItem selectionItem , TreeViewItem parent )
53+ private TreeViewItem AddGameObjectToHierarchy ( GameObject gameObject , GameObject rootGameObject , AnimationClip animationClip , TreeViewItem parent )
6354 {
64- string path = AnimationUtility . CalculateTransformPath ( gameObject . transform , selectionItem . rootGameObject . transform ) ;
55+ string path = AnimationUtility . CalculateTransformPath ( gameObject . transform , rootGameObject . transform ) ;
6556 TreeViewItem node = new AddCurvesPopupGameObjectNode ( gameObject , parent , gameObject . name ) ;
6657 List < TreeViewItem > childNodes = new List < TreeViewItem > ( ) ;
6758
6859 if ( m_RootItem == null )
6960 m_RootItem = node ;
7061
7162 // Iterate over all animatable objects
72- EditorCurveBinding [ ] allCurveBindings = AnimationUtility . GetAnimatableBindings ( gameObject , selectionItem . rootGameObject ) ;
63+ EditorCurveBinding [ ] allCurveBindings = AnimationUtility . GetAnimatableBindings ( gameObject , rootGameObject ) ;
7364 List < EditorCurveBinding > singleObjectBindings = new List < EditorCurveBinding > ( ) ;
7465 for ( int i = 0 ; i < allCurveBindings . Length ; i ++ )
7566 {
@@ -83,7 +74,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
8374 // Don't show for the root go
8475 if ( curveBinding . path != "" )
8576 {
86- TreeViewItem newNode = CreateNode ( selectionItem , singleObjectBindings . ToArray ( ) , node ) ;
77+ TreeViewItem newNode = CreateNode ( singleObjectBindings . ToArray ( ) , node ) ;
8778 if ( newNode != null )
8879 childNodes . Add ( newNode ) ;
8980 singleObjectBindings . Clear ( ) ;
@@ -104,7 +95,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
10495 isLastItemOnThisGroup = ( allCurveBindings [ i + 1 ] . type != curveBinding . type ) ;
10596
10697 // Let's not add those that already have a existing curve.
107- if ( AnimationWindowUtility . IsCurveCreated ( selectionItem . animationClip , curveBinding ) )
98+ if ( AnimationWindowUtility . IsCurveCreated ( animationClip , curveBinding ) )
10899 singleObjectBindings . Remove ( curveBinding ) ;
109100
110101 // Remove animator enabled property which shouldn't be animated.
@@ -113,7 +104,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
113104
114105 if ( ( isLastItemOverall || isLastItemOnThisGroup ) && singleObjectBindings . Count > 0 )
115106 {
116- childNodes . Add ( AddAnimatableObjectToHierarchy ( selectionItem , singleObjectBindings . ToArray ( ) , node , path ) ) ;
107+ childNodes . Add ( AddAnimatableObjectToHierarchy ( singleObjectBindings . ToArray ( ) , node , path ) ) ;
117108 singleObjectBindings . Clear ( ) ;
118109 }
119110 }
@@ -125,7 +116,7 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
125116 for ( int i = 0 ; i < gameObject . transform . childCount ; i ++ )
126117 {
127118 Transform childTransform = gameObject . transform . GetChild ( i ) ;
128- TreeViewItem childNode = AddGameObjectToHierarchy ( childTransform . gameObject , selectionItem , node ) ;
119+ TreeViewItem childNode = AddGameObjectToHierarchy ( childTransform . gameObject , rootGameObject , animationClip , node ) ;
129120 if ( childNode != null )
130121 childNodes . Add ( childNode ) ;
131122 }
@@ -135,14 +126,14 @@ private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, AnimationWi
135126 return node ;
136127 }
137128
138- private TreeViewItem AddScriptableObjectToHierarchy ( ScriptableObject scriptableObject , AnimationWindowSelectionItem selectionItem , TreeViewItem parent )
129+ private TreeViewItem AddScriptableObjectToHierarchy ( ScriptableObject scriptableObject , AnimationClip clip , TreeViewItem parent )
139130 {
140131 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 ( ) ;
142133
143134 TreeViewItem node = null ;
144135 if ( availableBindings . Length > 0 )
145- node = AddAnimatableObjectToHierarchy ( selectionItem , availableBindings , parent , "" ) ;
136+ node = AddAnimatableObjectToHierarchy ( availableBindings , parent , "" ) ;
146137 else
147138 node = new AddCurvesPopupObjectNode ( parent , "" , scriptableObject . name ) ;
148139
@@ -152,36 +143,36 @@ private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableO
152143 return node ;
153144 }
154145
155- static string GetClassName ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding binding )
146+ static string GetClassName ( EditorCurveBinding binding )
156147 {
157- if ( selectionItem . rootGameObject != null )
148+ if ( AddCurvesPopup . s_State . activeRootGameObject != null )
158149 {
159- Object target = AnimationUtility . GetAnimatedObject ( selectionItem . rootGameObject , binding ) ;
150+ Object target = AnimationUtility . GetAnimatedObject ( AddCurvesPopup . s_State . activeRootGameObject , binding ) ;
160151 if ( target )
161152 return ObjectNames . GetInspectorTitle ( target ) ;
162153 }
163154
164155 return binding . type . Name ;
165156 }
166157
167- static Texture2D GetIcon ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding binding )
158+ static Texture2D GetIcon ( EditorCurveBinding binding )
168159 {
169- if ( selectionItem . rootGameObject != null )
160+ if ( AddCurvesPopup . s_State . activeRootGameObject != null )
170161 {
171- return AssetPreview . GetMiniThumbnail ( AnimationUtility . GetAnimatedObject ( selectionItem . rootGameObject , binding ) ) ;
162+ return AssetPreview . GetMiniThumbnail ( AnimationUtility . GetAnimatedObject ( AddCurvesPopup . s_State . activeRootGameObject , binding ) ) ;
172163 }
173- else if ( selectionItem . scriptableObject != null )
164+ else if ( AddCurvesPopup . s_State . activeScriptableObject != null )
174165 {
175- return AssetPreview . GetMiniThumbnail ( selectionItem . scriptableObject ) ;
166+ return AssetPreview . GetMiniThumbnail ( AddCurvesPopup . s_State . activeScriptableObject ) ;
176167 }
177168
178169 return null ;
179170 }
180171
181- private TreeViewItem AddAnimatableObjectToHierarchy ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode , string path )
172+ private TreeViewItem AddAnimatableObjectToHierarchy ( EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode , string path )
182173 {
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 ] ) ;
185176
186177 List < TreeViewItem > childNodes = new List < TreeViewItem > ( ) ;
187178 List < EditorCurveBinding > singlePropertyBindings = new List < EditorCurveBinding > ( ) ;
@@ -195,7 +186,7 @@ private TreeViewItem AddAnimatableObjectToHierarchy(AnimationWindowSelectionItem
195186 // We expect curveBindings to come sorted by propertyname
196187 if ( i == curveBindings . Length - 1 || AnimationWindowUtility . GetPropertyGroupName ( curveBindings [ i + 1 ] . propertyName ) != AnimationWindowUtility . GetPropertyGroupName ( curveBinding . propertyName ) )
197188 {
198- TreeViewItem newNode = CreateNode ( selectionItem , singlePropertyBindings . ToArray ( ) , node ) ;
189+ TreeViewItem newNode = CreateNode ( singlePropertyBindings . ToArray ( ) , node ) ;
199190 if ( newNode != null )
200191 childNodes . Add ( newNode ) ;
201192 singlePropertyBindings . Clear ( ) ;
@@ -208,9 +199,9 @@ private TreeViewItem AddAnimatableObjectToHierarchy(AnimationWindowSelectionItem
208199 return node ;
209200 }
210201
211- private TreeViewItem CreateNode ( AnimationWindowSelectionItem selectionItem , EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode )
202+ private TreeViewItem CreateNode ( EditorCurveBinding [ ] curveBindings , TreeViewItem parentNode )
212203 {
213- var node = new AddCurvesPopupPropertyNode ( parentNode , selectionItem , curveBindings ) ;
204+ var node = new AddCurvesPopupPropertyNode ( parentNode , curveBindings ) ;
214205
215206 // For RectTransform.position we only want .z
216207 if ( AnimationWindowUtility . IsRectTransformPosition ( node . curveBindings [ 0 ] ) )
@@ -244,13 +235,11 @@ public AddCurvesPopupObjectNode(TreeViewItem parent, string path, string classNa
244235
245236 internal class AddCurvesPopupPropertyNode : TreeViewItem
246237 {
247- public AnimationWindowSelectionItem selectionItem ;
248238 public EditorCurveBinding [ ] curveBindings ;
249239
250- public AddCurvesPopupPropertyNode ( TreeViewItem parent , AnimationWindowSelectionItem selectionItem , EditorCurveBinding [ ] curveBindings )
240+ public AddCurvesPopupPropertyNode ( TreeViewItem parent , EditorCurveBinding [ ] curveBindings )
251241 : base ( curveBindings [ 0 ] . GetHashCode ( ) , parent . depth + 1 , parent , AnimationWindowUtility . NicifyPropertyGroupName ( curveBindings [ 0 ] . type , AnimationWindowUtility . GetPropertyGroupName ( curveBindings [ 0 ] . propertyName ) ) )
252242 {
253- this . selectionItem = selectionItem ;
254243 this . curveBindings = curveBindings ;
255244 }
256245
0 commit comments