SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
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.

27 lines
1.1 KiB

4 years ago
  1. # Custom equality comparers with equals operator
  2. If you need to compare Vectors using the overloaded operator == (see [Vector2.operator ==](https://docs.unity3d.com/ScriptReference/Vector2-operator_eq.html), [Vector3.operator ==](https://docs.unity3d.com/ScriptReference/Vector3-operator_eq.html), and [Vector4.operator ==](https://docs.unity3d.com/ScriptReference/Vector4-operator_eq.html)) you should use the respective comparer implementations:
  3. - Vector2ComparerWithEqualsOperator
  4. - Vector3ComparerWithEqualsOperator
  5. - Vector4ComparerWithEqualsOperator
  6. The interface is the same as for other [equality comparers](./reference-custom-equality-comparers.md) except the public [constructor](./reference-custom-equality-comparers.md#constructors) `error` parameter is inapplicable in this case.
  7. ## Example
  8. ```c#
  9. [TestFixture]
  10. public class Vector3Test
  11. {
  12. [Test]
  13. public void VerifyThat_TwoVector3ObjectsAreEqual()
  14. {
  15. var actual = new Vector3(10e-7f, 10e-7f, 10e-7f);
  16. var expected = new Vector3(0f, 0f, 0f);
  17. Assert.That(actual, Is.EqualTo(expected).Using(Vector3ComparerWithEqualsOperator.Instance));
  18. }
  19. }
  20. ```