XVector3.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using UnityEngine;
  3. namespace PublicTools.Unity
  4. {
  5. public struct XVector3
  6. {
  7. //
  8. // 摘要:
  9. // X component of the vector.
  10. public float x;
  11. //
  12. // 摘要:
  13. // Y component of the vector.
  14. public float y;
  15. //
  16. // 摘要:
  17. // Z component of the vector.
  18. public float z;
  19. public XVector3(float x, float y, float z)
  20. {
  21. this.x = x;
  22. this.y = y;
  23. this.z = z;
  24. }
  25. public XVector3(Vector3 vector3)
  26. {
  27. this.x = vector3.x;
  28. this.y = vector3.y;
  29. this.z = vector3.z;
  30. }
  31. public XVector3(Vector3 vector3, int count)
  32. {
  33. this.x = (float)Math.Round(vector3.x, count);
  34. this.y = (float)Math.Round(vector3.y, count);
  35. this.z = (float)Math.Round(vector3.z, count);
  36. }
  37. public Vector3 Trans()
  38. {
  39. Vector3 vector = Vector3.zero;
  40. vector.x = this.x;
  41. vector.y = this.y;
  42. vector.z = this.z;
  43. return vector;
  44. }
  45. //public override string ToString()
  46. //{
  47. // return JsonConvert.SerializeObject(this);
  48. //}
  49. }
  50. }