AMRotationKey.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. [Serializable]
  6. public class AMRotationKey : AMKey
  7. {
  8. public bool setRotation(Vector3 rotation)
  9. {
  10. if (this.rotation != Quaternion.Euler(rotation))
  11. {
  12. this.rotation = Quaternion.Euler(rotation);
  13. return true;
  14. }
  15. return false;
  16. }
  17. public Vector3 getRotation()
  18. {
  19. return this.rotation.eulerAngles;
  20. }
  21. public bool setRotationQuaternion(Vector4 rotation)
  22. {
  23. Quaternion rhs = new Quaternion(rotation.x, rotation.y, rotation.z, rotation.w);
  24. if (this.rotation != rhs)
  25. {
  26. this.rotation = rhs;
  27. return true;
  28. }
  29. return false;
  30. }
  31. public Vector4 getRotationQuaternion()
  32. {
  33. return new Vector4(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w);
  34. }
  35. public override AMKey CreateClone()
  36. {
  37. AMRotationKey amrotationKey = ScriptableObject.CreateInstance<AMRotationKey>();
  38. amrotationKey.frame = this.frame;
  39. amrotationKey.rotation = this.rotation;
  40. amrotationKey.easeType = this.easeType;
  41. amrotationKey.customEase = new List<float>(this.customEase);
  42. return amrotationKey;
  43. }
  44. public override void CreateFromStringData(string data_text)
  45. {
  46. string[] array = data_text.Split(new char[]
  47. {
  48. ':'
  49. });
  50. if (array.Length == 0 || array[0] != "Rotation")
  51. {
  52. return;
  53. }
  54. int num = 1;
  55. this.frame = int.Parse(array[num++]);
  56. this.rotation = Parse.Quaternion(array[num++]);
  57. this.easeType = int.Parse(array[num++]);
  58. int num2 = int.Parse(array[num++]);
  59. this.customEase = new List<float>();
  60. for (int i = 0; i < num2; i++)
  61. {
  62. this.customEase.Add(float.Parse(array[num++]));
  63. }
  64. }
  65. public override string ToStringData()
  66. {
  67. List<string> list = new List<string>();
  68. list.Add("Rotation");
  69. list.Add(this.frame.ToString());
  70. list.Add(this.rotation.ToString("G"));
  71. list.Add(this.easeType.ToString());
  72. list.Add(this.customEase.Count.ToString());
  73. foreach (float num in this.customEase)
  74. {
  75. list.Add(num.ToString());
  76. }
  77. string text = list[0];
  78. for (int i = 1; i < list.Count; i++)
  79. {
  80. text = text + ":" + list[i];
  81. }
  82. return text;
  83. }
  84. public Quaternion rotation;
  85. }