Skip to content

Commit bbd5f7a

Browse files
committed
大量更新
1 parent a21a05c commit bbd5f7a

File tree

88 files changed

+3778
-1126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3778
-1126
lines changed

Assets/Script/Core/AnimSystem/AnimData.cs

Lines changed: 125 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public class AnimData
2424
public float m_totalTime = 0;
2525
public int m_repeatCount = -1;
2626

27+
//Q4
28+
public Quaternion m_fromQ4;
29+
public Quaternion m_toQ4;
30+
2731
//V3
2832
public Vector4 m_fromV4;
2933
public Vector4 m_toV4;
@@ -73,12 +77,13 @@ public class AnimData
7377
//缓存变量
7478
RectTransform m_rectRransform;
7579
Transform m_transform;
80+
string gameObjectName;
7681

7782
#endregion
7883

7984
#region 核心函数
8085

81-
public void executeUpdate()
86+
public bool ExecuteUpdate()
8287
{
8388
if (m_delayTime <= 0)
8489
{
@@ -123,6 +128,8 @@ public void executeUpdate()
123128
case AnimType.LocalScale: LocalScale(); break;
124129
case AnimType.LocalRotate: LocalRotate(); break;
125130
case AnimType.Rotate: Rotate(); break;
131+
case AnimType.LocalRotation:LocalRotation();break;
132+
case AnimType.Rotation:Rotation();break;
126133

127134
case AnimType.Color: UpdateColor(); break;
128135
case AnimType.Alpha: UpdateAlpha(); break;
@@ -137,8 +144,10 @@ public void executeUpdate()
137144
}
138145
catch (Exception e)
139146
{
140-
Debug.LogError("AnimSystem Error Exception: " + e.ToString());
147+
Debug.LogError("AnimSystem Error ! GameObjectName: " + gameObjectName + " Exception: " + e.ToString());
148+
return true;
141149
}
150+
return false;
142151
}
143152

144153
//动画播放完毕执行回调
@@ -228,6 +237,16 @@ public void ExchangeAlpha()
228237

229238
public void Init()
230239
{
240+
if (m_animGameObejct != null)
241+
{
242+
gameObjectName = m_animGameObejct.name;
243+
}
244+
else
245+
{
246+
gameObjectName = "customMethod";
247+
}
248+
249+
231250
switch (m_animType)
232251
{
233252
case AnimType.UGUI_Color: UguiColorInit(m_isChild); break;
@@ -243,6 +262,9 @@ public void Init()
243262
case AnimType.LocalScale: TransfromInit(); break;
244263
case AnimType.LocalRotate: TransfromInit(); break;
245264
case AnimType.Rotate: TransfromInit(); break;
265+
case AnimType.LocalRotation: TransfromInit(); break;
266+
case AnimType.Rotation: TransfromInit(); break;
267+
246268
}
247269

248270
if (m_pathType != PathType.Line)
@@ -383,50 +405,44 @@ Vector3 Bezier3(Vector3 startPos, Vector3 endPos, float n_time, Vector3[] t_Cont
383405

384406
#region UGUI_Color
385407

386-
List<Image> m_animObjectList_Image = new List<Image>();
387-
List<Text> m_animObjectList_Text = new List<Text>();
408+
List<Graphic> m_graphicList_Image = new List<Graphic>();
409+
//List<RawImage> m_rawImageList_Text = new List<RawImage>();
410+
//List<Text> m_animObjectList_Text = new List<Text>();
388411

389412
#region ALpha
390413

391414
public void UguiAlphaInit(bool isChild)
392415
{
393-
m_animObjectList_Image.Clear();
394-
m_animObjectList_Text.Clear();
416+
m_graphicList_Image.Clear();
395417
m_oldColor.Clear();
396418

397419
if (isChild)
398420
{
399-
Image[] images = m_animGameObejct.GetComponentsInChildren<Image>(true);
421+
Graphic[] images = m_animGameObejct.GetComponentsInChildren<Graphic>(true);
400422
for (int i = 0; i < images.Length; i++)
401423
{
402424
if (images[i].transform.GetComponent<Mask>() == null)
403425
{
404-
m_animObjectList_Image.Add(images[i]);
426+
m_graphicList_Image.Add(images[i]);
405427
m_oldColor.Add(images[i].color);
406428
}
407429
}
408430

409-
Text[] texts = m_animGameObejct.GetComponentsInChildren<Text>(true);
431+
//Text[] texts = m_animGameObejct.GetComponentsInChildren<Text>(true);
410432

411-
for (int i = 0; i < texts.Length; i++)
412-
{
413-
m_animObjectList_Text.Add(texts[i]);
414-
m_oldColor.Add(texts[i].color);
415-
}
433+
//for (int i = 0; i < texts.Length; i++)
434+
//{
435+
// m_animObjectList_Text.Add(texts[i]);
436+
// m_oldColor.Add(texts[i].color);
437+
//}
416438
}
417439
else
418440
{
419-
Image image = m_animGameObejct.GetComponent<Image>();
420-
Text text = m_animGameObejct.GetComponent<Text>();
421-
if (image != null)
441+
Graphic gra = m_animGameObejct.GetComponent<Graphic>();
442+
if (gra != null)
422443
{
423-
m_animObjectList_Image.Add(image);
424-
m_oldColor.Add(image.color);
425-
}
426-
if (text != null)
427-
{
428-
m_animObjectList_Text.Add(text);
429-
m_oldColor.Add(text.color);
444+
m_graphicList_Image.Add(gra);
445+
m_oldColor.Add(gra.color);
430446
}
431447
}
432448

@@ -444,23 +460,23 @@ public void SetUGUIAlpha(float a)
444460
Color newColor = colTmp;
445461

446462
int index = 0;
447-
for (int i = 0; i < m_animObjectList_Image.Count; i++)
463+
for (int i = 0; i < m_graphicList_Image.Count; i++)
448464
{
449465
newColor = m_oldColor[index];
450466
newColor.a = a;
451-
m_animObjectList_Image[i].color = newColor;
467+
m_graphicList_Image[i].color = newColor;
452468

453469
index++;
454470
}
455471

456-
for (int i = 0; i < m_animObjectList_Text.Count; i++)
457-
{
458-
newColor = m_oldColor[index];
459-
newColor.a = a;
460-
m_animObjectList_Text[i].color = newColor;
472+
//for (int i = 0; i < m_graphicList_Image.Count; i++)
473+
//{
474+
// newColor = m_oldColor[index];
475+
// newColor.a = a;
476+
// m_graphicList_Image[i].color = newColor;
461477

462-
index++;
463-
}
478+
// index++;
479+
//}
464480
}
465481

466482
#endregion
@@ -474,57 +490,57 @@ void UguiColor()
474490

475491
public void UguiColorInit(bool isChild)
476492
{
477-
m_animObjectList_Image.Clear();
478-
m_animObjectList_Text.Clear();
493+
m_graphicList_Image.Clear();
494+
//m_animObjectList_Text.Clear();
479495

480496
if (isChild)
481497
{
482-
Image[] images = m_animGameObejct.GetComponentsInChildren<Image>();
498+
Graphic[] images = m_animGameObejct.GetComponentsInChildren<Graphic>();
483499
for (int i = 0; i < images.Length; i++)
484500
{
485501
if (images[i].transform.GetComponent<Mask>() == null)
486502
{
487-
m_animObjectList_Image.Add(images[i]);
503+
m_graphicList_Image.Add(images[i]);
488504
}
489505
else
490506
{
491507
//Debug.LogError("name:" + images[i].gameObject.name);
492508
}
493509
}
494-
Text[] texts = m_animGameObejct.GetComponentsInChildren<Text>();
510+
//Text[] texts = m_animGameObejct.GetComponentsInChildren<Text>();
495511

496-
for (int i = 0; i < texts.Length; i++)
497-
{
498-
m_animObjectList_Text.Add(texts[i]);
499-
}
512+
//for (int i = 0; i < texts.Length; i++)
513+
//{
514+
// m_graphicList_Image.Add(texts[i]);
515+
//}
500516
}
501517
else
502518
{
503519
Image image = m_animGameObejct.GetComponent<Image>();
504520
Text text = m_animGameObejct.GetComponent<Text>();
505521
if (image != null)
506522
{
507-
m_animObjectList_Image.Add(image);
508-
}
509-
if (text != null)
510-
{
511-
m_animObjectList_Text.Add(text);
523+
m_graphicList_Image.Add(image);
512524
}
525+
//if (text != null)
526+
//{
527+
// m_animObjectList_Text.Add(text);
528+
//}
513529
}
514530
SetUGUIColor(m_fromColor);
515531
}
516532

517533
void SetUGUIColor(Color color)
518534
{
519-
for (int i = 0; i < m_animObjectList_Image.Count; i++)
535+
for (int i = 0; i < m_graphicList_Image.Count; i++)
520536
{
521-
m_animObjectList_Image[i].color = color;
537+
m_graphicList_Image[i].color = color;
522538
}
523539

524-
for (int i = 0; i < m_animObjectList_Text.Count; i++)
525-
{
526-
m_animObjectList_Text[i].color = color;
527-
}
540+
//for (int i = 0; i < m_graphicList_Image.Count; i++)
541+
//{
542+
// m_graphicList_Image[i].color = color;
543+
//}
528544
}
529545

530546

@@ -540,7 +556,7 @@ void SizeDelta()
540556
Debug.LogError(m_transform.name + "缺少RectTransform组件,不能进行sizeDelta变换!!");
541557
return;
542558
}
543-
m_rectRransform.sizeDelta = GetInterpolationV3(m_fromV2, m_toV2);
559+
m_rectRransform.sizeDelta = GetInterpolationV2(m_fromV2, m_toV2);
544560
}
545561

546562
#endregion
@@ -557,6 +573,7 @@ void UguiPosition()
557573
m_rectRransform.anchoredPosition3D = GetInterpolationV3(m_fromV3, m_toV3);
558574
}
559575

576+
560577
#endregion
561578

562579
#endregion
@@ -590,11 +607,23 @@ void LocalRotate()
590607
m_transform.localEulerAngles = GetInterpolationV3(m_fromV3, m_toV3);
591608
}
592609

610+
611+
void LocalRotation()
612+
{
613+
m_transform.localRotation = GetInterpolationQ4(m_fromQ4, m_toQ4);
614+
615+
}
616+
593617
void Rotate()
594618
{
595619
m_transform.eulerAngles = GetInterpolationV3(m_fromV3, m_toV3);
596620
}
597621

622+
void Rotation()
623+
{
624+
m_transform.rotation = GetInterpolationQ4(m_fromQ4, m_toQ4);
625+
626+
}
598627
void LocalScale()
599628
{
600629
m_transform.localScale = GetInterpolationV3(m_fromV3, m_toV3);
@@ -811,6 +840,25 @@ Vector3 GetInterpolationV4(Vector4 oldValue, Vector4 aimValue)
811840
return result;
812841
}
813842

843+
Vector3 GetInterpolationV2(Vector2 oldValue, Vector2 aimValue)
844+
{
845+
Vector2 result = Vector2.zero;
846+
847+
if (m_pathType == PathType.Line)
848+
{
849+
result = new Vector2(
850+
GetInterpolation(oldValue.x, aimValue.x),
851+
GetInterpolation(oldValue.y, aimValue.y)
852+
);
853+
}
854+
else
855+
{
856+
result = GetBezierInterpolationV3(oldValue, aimValue);
857+
}
858+
859+
return result;
860+
}
861+
814862
Vector3 GetInterpolationV3(Vector3 oldValue, Vector3 aimValue)
815863
{
816864
Vector3 result = Vector3.zero;
@@ -831,6 +879,28 @@ Vector3 GetInterpolationV3(Vector3 oldValue, Vector3 aimValue)
831879
return result;
832880
}
833881

882+
883+
Quaternion GetInterpolationQ4(Quaternion oldValue, Quaternion aimValue)
884+
{
885+
Quaternion result = Quaternion.Euler(Vector3.zero);
886+
887+
if (m_pathType == PathType.Line)
888+
{
889+
result = new Quaternion(
890+
GetInterpolation(oldValue.x, aimValue.x),
891+
GetInterpolation(oldValue.y, aimValue.y),
892+
GetInterpolation(oldValue.z, aimValue.z),
893+
GetInterpolation(oldValue.w, aimValue.w)
894+
);
895+
}
896+
else
897+
{
898+
//result = GetBezierInterpolationV3(oldValue, aimValue);
899+
}
900+
901+
return result;
902+
}
903+
834904
Color GetInterpolationColor(Color oldValue, Color aimValue)
835905
{
836906
Color result = new Color(GetInterpolation(oldValue.r, aimValue.r),
@@ -857,7 +927,7 @@ public float OutBack(float b, float to, float t, float d, float s = 1.70158f)
857927
float c = to - b;
858928

859929
t = t / d - 1;
860-
930+
//Debug.LogWarning(c * (t * t * ((s + 1) * t + s) + 1) + b);
861931
return c * (t * t * ((s + 1) * t + s) + 1) + b;
862932

863933
}

0 commit comments

Comments
 (0)