AMAnimationKey.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. [Serializable]
  5. public class AMAnimationKey : AMKey
  6. {
  7. public bool setWrapMode(WrapMode wrapMode)
  8. {
  9. if (this.wrapMode != wrapMode)
  10. {
  11. this.wrapMode = wrapMode;
  12. return true;
  13. }
  14. return false;
  15. }
  16. public bool setAmClip(AnimationClip clip)
  17. {
  18. if (this.amClip != clip)
  19. {
  20. this.amClip = clip;
  21. return true;
  22. }
  23. return false;
  24. }
  25. public bool setCrossFade(bool crossfade)
  26. {
  27. if (this.crossfade != crossfade)
  28. {
  29. this.crossfade = crossfade;
  30. return true;
  31. }
  32. return false;
  33. }
  34. public bool setCrossfadeTime(float crossfadeTime)
  35. {
  36. if (this.crossfadeTime != crossfadeTime)
  37. {
  38. this.crossfadeTime = crossfadeTime;
  39. return true;
  40. }
  41. return false;
  42. }
  43. public override AMKey CreateClone()
  44. {
  45. AMAnimationKey amanimationKey = ScriptableObject.CreateInstance<AMAnimationKey>();
  46. amanimationKey.frame = this.frame;
  47. amanimationKey.wrapMode = this.wrapMode;
  48. amanimationKey.amClip = this.amClip;
  49. amanimationKey.crossfade = this.crossfade;
  50. return amanimationKey;
  51. }
  52. public override void CreateFromStringData(string data_text)
  53. {
  54. string[] array = data_text.Split(new char[]
  55. {
  56. ':'
  57. });
  58. if (array.Length == 0 || array[0] != "Animation")
  59. {
  60. return;
  61. }
  62. NDebug.Assert(this.obj != null, "AMAnimationKey::CreateFromStringData\nobjがnullです");
  63. this.amClip = null;
  64. int num = 1;
  65. this.frame = int.Parse(array[num++]);
  66. this.wrapMode = (WrapMode)Enum.Parse(typeof(WrapMode), array[num++]);
  67. bool flag = bool.Parse(array[num++]);
  68. if (flag)
  69. {
  70. Animation[] components = this.obj.GetComponents<Animation>();
  71. NDebug.Assert(components.Length != 0, "Animation取得失敗");
  72. string str = array[num++];
  73. NDebug.Assert(this.amClip != null, "AnimationClip[" + str + "]の取得に失敗しました");
  74. }
  75. this.crossfade = bool.Parse(array[num++]);
  76. }
  77. public override string ToStringData()
  78. {
  79. List<string> list = new List<string>();
  80. list.Add("Animation");
  81. list.Add(this.frame.ToString());
  82. list.Add(this.wrapMode.ToString());
  83. list.Add((this.amClip != null).ToString());
  84. string text = list[0];
  85. for (int i = 1; i < list.Count; i++)
  86. {
  87. text = text + ":" + list[i];
  88. }
  89. return text;
  90. }
  91. public WrapMode wrapMode;
  92. public GameObject obj;
  93. public AnimationClip amClip;
  94. public bool crossfade = true;
  95. public float crossfadeTime = 0.3f;
  96. }