2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
2.0 KiB

5 years ago
  1. //========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
  2. using System;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace HTC.UnityPlugin.Utility
  6. {
  7. public static class ChangeProp
  8. {
  9. public static bool Set<T>(ref T currentValue, T newValue, Func<T, T, bool> equalFunc = null)
  10. {
  11. if (equalFunc == null)
  12. {
  13. if (EqualityComparer<T>.Default.Equals(currentValue, newValue)) { return false; }
  14. }
  15. else
  16. {
  17. if (equalFunc(currentValue, newValue)) { return false; }
  18. }
  19. currentValue = newValue;
  20. return true;
  21. }
  22. public static bool Vector3Equal(Vector3 a, Vector3 b) { return a == b; } // (a-b).mag < Vector3.kEpsilon
  23. public static bool Vector3AxisApprox(Vector3 a, Vector3 b) { return Mathf.Approximately(a.x, b.x) && Mathf.Approximately(a.y, b.y) && Mathf.Approximately(a.z, b.z); }
  24. public static bool Vector3DistanceApprox(Vector3 a, Vector3 b) { return Mathf.Approximately((a - b).sqrMagnitude, 0f); }
  25. public static bool Vector2Equal(Vector2 a, Vector2 b) { return a == b; } // (a-b).mag < Vector2.kEpsilon
  26. public static bool Vector2AxisApprox(Vector2 a, Vector2 b) { return Mathf.Approximately(a.x, b.x) && Mathf.Approximately(a.y, b.y); }
  27. public static bool Vector2DistanceApprox(Vector2 a, Vector2 b) { return Mathf.Approximately((a - b).sqrMagnitude, 0f); }
  28. public static bool QuaternionEqual(Quaternion a, Quaternion b) { return a == b; } // Dot(a,b) > 1f - Quaternion.kEpsilon
  29. public static bool QuaternionAngleApprox(Quaternion a, Quaternion b) { return Mathf.Approximately(Quaternion.Angle(a, b), 0f); }
  30. public static bool StringEmptyEqual(string a, string b)
  31. {
  32. var aEmpty = string.IsNullOrEmpty(a);
  33. var bEmpty = string.IsNullOrEmpty(b);
  34. return aEmpty ? bEmpty : (!bEmpty && a == b);
  35. }
  36. }
  37. }