Skip to content

Commit 8cee044

Browse files
committed
fixed the bug of animation Data
1 parent 6af607b commit 8cee044

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

Editor/Export/utils/AnimationCurveGroup.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public AnimationCurveGroup(string path, GameObject gameObject, Type type, string
277277
this._conpomentType = conpomentType;
278278
this._propnames = new List<string>();
279279
this._type = type;
280-
this._propertyName = propertyName;
280+
this._propertyName = propertyName.Split(".")[0];
281281
this._timeLists = new Dictionary<uint, float>();
282282
this.datas = new Dictionary<float, FrameData>();
283283
}
@@ -307,18 +307,19 @@ public KeyFrameValueType keyType
307307

308308
public bool pushCurve(AnimationClipCurveData curveData)
309309
{
310-
if (this._path != AnimationCurveGroup.getCurvePath(curveData))
310+
if (this._path != curveData.path)
311311
{
312312
return false;
313313
}
314+
string[] propertyNames = curveData.propertyName.Split('.');
315+
if (propertyNames[0] != this._propertyName) return false;
314316
string endKey = null;
315317
if (this._keyType == KeyFrameValueType.Float)
316318
{
317319
endKey = "x";
318320
}
319321
else
320322
{
321-
string[] propertyNames = curveData.propertyName.Split('.');
322323
endKey = propertyNames[propertyNames.Length - 1];
323324
}
324325

@@ -431,7 +432,7 @@ public void getAnimaFameData(ref AniNodeData aniNodeData, ref Dictionary<uint, F
431432
}
432433
aniNodeData.type = (Byte)this._keyType;
433434
List<UInt16> pathIndex = new List<UInt16>();
434-
String nodePath = this._path.Split('.')[0];
435+
String nodePath = this._path;
435436
string[] strArr = nodePath.Split('/');
436437
for (int m = 0; m < strArr.Length; m++)
437438
{

Editor/Export/utils/GameObjectUitls.cs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public static bool isCameraOrLight(GameObject gameObject)
6969
if (gameObject.GetComponent<Camera>() != null)
7070
{
7171
return true;
72-
}else if (gameObject.GetComponent<Light>() != null)
72+
}
73+
else if (gameObject.GetComponent<Light>() != null)
7374
{
7475
return true;
7576
}
@@ -78,7 +79,7 @@ public static bool isCameraOrLight(GameObject gameObject)
7879
return false;
7980
}
8081
}
81-
82+
8283

8384
private const byte k_MaxByteForOverexposedColor = 191;
8485
public static void DecomposeHdrColor(Color linearColorHdr, out Color baseLinearColor, out float exposure)
@@ -120,27 +121,27 @@ public static string cleanIllegalChar(string str, bool heightLevel)
120121
}
121122
return str;
122123
}
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)
125125
{
126126
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")
129130
{
130131
propNames = "localPosition";
131132
keyType = KeyFrameValueType.Position;
132133
}
133-
else if (propNames == "m_LocalRotation")
134+
else if (property == "m_LocalRotation")
134135
{
135136
propNames = "localRotation";
136137
keyType = KeyFrameValueType.Rotation;
137138
}
138-
else if (propNames == "m_LocalScale")
139+
else if (property == "m_LocalScale")
139140
{
140141
propNames = "localScale";
141142
keyType = KeyFrameValueType.Scale;
142143
}
143-
else if (propNames == "localEulerAnglesRaw")
144+
else if (property == "localEulerAnglesRaw")
144145
{
145146
propNames = "localRotationEuler";
146147
keyType = KeyFrameValueType.RotationEuler;
@@ -150,13 +151,11 @@ private static AnimationCurveGroup readTransfromAnimation(EditorCurveBinding bin
150151
return null;
151152
}
152153
string conpomentType = searchCompoment[binding.type.ToString()];
153-
string propertyName = binding.propertyName;
154-
propertyName = propertyName.Substring(0, propertyName.LastIndexOf("."));
155154
AnimationCurveGroup curveGroup = new AnimationCurveGroup(path, gameObject, binding.type, conpomentType, propertyName, keyType);
156155
curveGroup.propnames.Add(propNames);
157156
return curveGroup;
158157
}
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)
160159
{
161160
PropertyInfo info = targetObject.GetType().GetProperty("material");
162161
Material material = (Material)info.GetValue(targetObject);
@@ -166,7 +165,7 @@ private static AnimationCurveGroup readMaterAnimation(EditorCurveBinding binding
166165
{
167166
return null;
168167
}
169-
string propNames = binding.propertyName.Split('.')[1];
168+
string propNames = binding.propertyName;
170169
KeyFrameValueType keyType;
171170
if (propsData.floatLists.ContainsKey(propNames))
172171
{
@@ -188,15 +187,12 @@ private static AnimationCurveGroup readMaterAnimation(EditorCurveBinding binding
188187
return null;
189188
}
190189
string conpomentType = searchCompoment[binding.type.ToString()];
191-
string propertyName = binding.propertyName;
192-
propertyName = propertyName.Substring(0, propertyName.LastIndexOf("."));
193190
AnimationCurveGroup curveGroup = new AnimationCurveGroup(path, gameObject, binding.type, conpomentType, propertyName, keyType);
194191
curveGroup.propnames.Add("sharedMaterials");
195192
curveGroup.propnames.Add("0");
196193
curveGroup.propnames.Add(propNames);
197194
return curveGroup;
198195
}
199-
200196
public static void writeClip(AnimationClip aniclip, FileStream fs, GameObject gameObject, string clipName)
201197
{
202198

@@ -259,15 +255,15 @@ public static void writeClip(AnimationClip aniclip, FileStream fs, GameObject ga
259255
EditorCurveBinding binding = editorCurveBindings[j];
260256
if (binding.type == typeof(Transform))
261257
{
262-
curveGroup = readTransfromAnimation(binding, child, targetObject, path);
258+
curveGroup = readTransfromAnimation(binding, child, targetObject, curveData.path, curveData.propertyName);
263259
}
264260
else if (binding.type == typeof(RectTransform))
265261
{
266-
curveGroup = readTransfromAnimation(binding, child, targetObject, path);
262+
curveGroup = readTransfromAnimation(binding, child, targetObject, curveData.path, curveData.propertyName);
267263
}
268264
else if (typeof(Renderer).IsAssignableFrom(binding.type))
269265
{
270-
curveGroup = readMaterAnimation(binding, child, targetObject, path);
266+
curveGroup = readMaterAnimation(binding, child, targetObject, curveData.path, curveData.propertyName);
271267
}
272268
if (curveGroup != null)
273269
{
@@ -361,21 +357,21 @@ public static void writeClip(AnimationClip aniclip, FileStream fs, GameObject ga
361357
for (int j = 0; j < startTimeList.Count; j++)
362358
{
363359
Util.FileUtil.WriteData(fs, (float)startTimeList[j]);
364-
}
360+
}
365361

366362
Util.FileUtil.WriteData(fs, (UInt16)stringDatas.IndexOf(clipName));//动画名字符索引
367363

368364
float aniTotalTime = startTimeList.Count == 0 ? 0.0f : (float)startTimeList[startTimeList.Count - 1];
369365
Util.FileUtil.WriteData(fs, aniTotalTime);///动画总时长
370-
if(aniclip.wrapMode == WrapMode.Loop)
366+
if (aniclip.wrapMode == WrapMode.Loop)
371367
{
372368
Util.FileUtil.WriteData(fs, true);
373369
}
374370
else
375371
{
376372
Util.FileUtil.WriteData(fs, aniclip.isLooping);//动画是否循环
377373
}
378-
374+
379375

380376
Util.FileUtil.WriteData(fs, (UInt16)clipFrameRate);//frameRate
381377

0 commit comments

Comments
 (0)