@@ -69,7 +69,8 @@ public static bool isCameraOrLight(GameObject gameObject)
69
69
if ( gameObject . GetComponent < Camera > ( ) != null )
70
70
{
71
71
return true ;
72
- } else if ( gameObject . GetComponent < Light > ( ) != null )
72
+ }
73
+ else if ( gameObject . GetComponent < Light > ( ) != null )
73
74
{
74
75
return true ;
75
76
}
@@ -78,7 +79,7 @@ public static bool isCameraOrLight(GameObject gameObject)
78
79
return false ;
79
80
}
80
81
}
81
-
82
+
82
83
83
84
private const byte k_MaxByteForOverexposedColor = 191 ;
84
85
public static void DecomposeHdrColor ( Color linearColorHdr , out Color baseLinearColor , out float exposure )
@@ -120,27 +121,27 @@ public static string cleanIllegalChar(string str, bool heightLevel)
120
121
}
121
122
return str ;
122
123
}
123
-
124
- private static AnimationCurveGroup readTransfromAnimation ( EditorCurveBinding binding , GameObject gameObject , object targetObject , string path )
124
+ private static AnimationCurveGroup readTransfromAnimation ( EditorCurveBinding binding , GameObject gameObject , object targetObject , string path , string propertyName )
125
125
{
126
126
KeyFrameValueType keyType ;
127
- string propNames = binding . propertyName . Split ( '.' ) [ 0 ] ;
128
- if ( propNames == "m_LocalPosition" )
127
+ string propNames = "" ;
128
+ string property = propertyName . Split ( "." ) [ 0 ] ;
129
+ if ( property == "m_LocalPosition" )
129
130
{
130
131
propNames = "localPosition" ;
131
132
keyType = KeyFrameValueType . Position ;
132
133
}
133
- else if ( propNames == "m_LocalRotation" )
134
+ else if ( property == "m_LocalRotation" )
134
135
{
135
136
propNames = "localRotation" ;
136
137
keyType = KeyFrameValueType . Rotation ;
137
138
}
138
- else if ( propNames == "m_LocalScale" )
139
+ else if ( property == "m_LocalScale" )
139
140
{
140
141
propNames = "localScale" ;
141
142
keyType = KeyFrameValueType . Scale ;
142
143
}
143
- else if ( propNames == "localEulerAnglesRaw" )
144
+ else if ( property == "localEulerAnglesRaw" )
144
145
{
145
146
propNames = "localRotationEuler" ;
146
147
keyType = KeyFrameValueType . RotationEuler ;
@@ -150,13 +151,11 @@ private static AnimationCurveGroup readTransfromAnimation(EditorCurveBinding bin
150
151
return null ;
151
152
}
152
153
string conpomentType = searchCompoment [ binding . type . ToString ( ) ] ;
153
- string propertyName = binding . propertyName ;
154
- propertyName = propertyName . Substring ( 0 , propertyName . LastIndexOf ( "." ) ) ;
155
154
AnimationCurveGroup curveGroup = new AnimationCurveGroup ( path , gameObject , binding . type , conpomentType , propertyName , keyType ) ;
156
155
curveGroup . propnames . Add ( propNames ) ;
157
156
return curveGroup ;
158
157
}
159
- private static AnimationCurveGroup readMaterAnimation ( EditorCurveBinding binding , GameObject gameObject , object targetObject , string path )
158
+ private static AnimationCurveGroup readMaterAnimation ( EditorCurveBinding binding , GameObject gameObject , object targetObject , string path , string propertyName )
160
159
{
161
160
PropertyInfo info = targetObject . GetType ( ) . GetProperty ( "material" ) ;
162
161
Material material = ( Material ) info . GetValue ( targetObject ) ;
@@ -166,7 +165,7 @@ private static AnimationCurveGroup readMaterAnimation(EditorCurveBinding binding
166
165
{
167
166
return null ;
168
167
}
169
- string propNames = binding . propertyName . Split ( '.' ) [ 1 ] ;
168
+ string propNames = binding . propertyName ;
170
169
KeyFrameValueType keyType ;
171
170
if ( propsData . floatLists . ContainsKey ( propNames ) )
172
171
{
@@ -188,15 +187,12 @@ private static AnimationCurveGroup readMaterAnimation(EditorCurveBinding binding
188
187
return null ;
189
188
}
190
189
string conpomentType = searchCompoment [ binding . type . ToString ( ) ] ;
191
- string propertyName = binding . propertyName ;
192
- propertyName = propertyName . Substring ( 0 , propertyName . LastIndexOf ( "." ) ) ;
193
190
AnimationCurveGroup curveGroup = new AnimationCurveGroup ( path , gameObject , binding . type , conpomentType , propertyName , keyType ) ;
194
191
curveGroup . propnames . Add ( "sharedMaterials" ) ;
195
192
curveGroup . propnames . Add ( "0" ) ;
196
193
curveGroup . propnames . Add ( propNames ) ;
197
194
return curveGroup ;
198
195
}
199
-
200
196
public static void writeClip ( AnimationClip aniclip , FileStream fs , GameObject gameObject , string clipName )
201
197
{
202
198
@@ -259,15 +255,15 @@ public static void writeClip(AnimationClip aniclip, FileStream fs, GameObject ga
259
255
EditorCurveBinding binding = editorCurveBindings [ j ] ;
260
256
if ( binding . type == typeof ( Transform ) )
261
257
{
262
- curveGroup = readTransfromAnimation ( binding , child , targetObject , path ) ;
258
+ curveGroup = readTransfromAnimation ( binding , child , targetObject , curveData . path , curveData . propertyName ) ;
263
259
}
264
260
else if ( binding . type == typeof ( RectTransform ) )
265
261
{
266
- curveGroup = readTransfromAnimation ( binding , child , targetObject , path ) ;
262
+ curveGroup = readTransfromAnimation ( binding , child , targetObject , curveData . path , curveData . propertyName ) ;
267
263
}
268
264
else if ( typeof ( Renderer ) . IsAssignableFrom ( binding . type ) )
269
265
{
270
- curveGroup = readMaterAnimation ( binding , child , targetObject , path ) ;
266
+ curveGroup = readMaterAnimation ( binding , child , targetObject , curveData . path , curveData . propertyName ) ;
271
267
}
272
268
if ( curveGroup != null )
273
269
{
@@ -361,21 +357,21 @@ public static void writeClip(AnimationClip aniclip, FileStream fs, GameObject ga
361
357
for ( int j = 0 ; j < startTimeList . Count ; j ++ )
362
358
{
363
359
Util . FileUtil . WriteData ( fs , ( float ) startTimeList [ j ] ) ;
364
- }
360
+ }
365
361
366
362
Util . FileUtil . WriteData ( fs , ( UInt16 ) stringDatas . IndexOf ( clipName ) ) ; //动画名字符索引
367
363
368
364
float aniTotalTime = startTimeList . Count == 0 ? 0.0f : ( float ) startTimeList [ startTimeList . Count - 1 ] ;
369
365
Util . FileUtil . WriteData ( fs , aniTotalTime ) ; ///动画总时长
370
- if ( aniclip . wrapMode == WrapMode . Loop )
366
+ if ( aniclip . wrapMode == WrapMode . Loop )
371
367
{
372
368
Util . FileUtil . WriteData ( fs , true ) ;
373
369
}
374
370
else
375
371
{
376
372
Util . FileUtil . WriteData ( fs , aniclip . isLooping ) ; //动画是否循环
377
373
}
378
-
374
+
379
375
380
376
Util . FileUtil . WriteData ( fs , ( UInt16 ) clipFrameRate ) ; //frameRate
381
377
0 commit comments