Version: 2022.3

Vector3.operator ==

切换到手册
public static bool operator == (Vector3 lhs, Vector3 rhs);

描述

如果两个向量大致相等,则返回 true。

考虑到浮点值的不准确性,如果两个向量的差值小于 1e-5,则认为它们是相等的。

另请参阅:Equals

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform other;

void Example() { if (other && transform.position == other.position) { print("I'm at the same place as the other transform!"); } } }