static private getClosestPointOnSurfaceBox ( BoxCollider box, Vector3 point ) : Vector3 | ||
box | BoxCollider | |
point | Vector3 | |
Résultat | Vector3 |
public static Vector3 GetClosestPointOnBoundary(Moba_Camera_Boundary boundary, Vector3 point) { Vector3 result = point; if (boundary.type == Moba_Camera_Boundaries.BoundaryType.cube) { BoxCollider component = boundary.GetComponent <BoxCollider>(); result = Moba_Camera_Boundaries.getClosestPointOnSurfaceBox(component, point); } else if (boundary.type == Moba_Camera_Boundaries.BoundaryType.sphere) { SphereCollider component2 = boundary.GetComponent <SphereCollider>(); Vector3 vector = boundary.transform.position + component2.center; float radius = component2.radius; result = vector + (point - vector).normalized * radius; } return(result); }
public static Moba_Camera_Boundary GetClosestBoundary(Vector3 point) { Moba_Camera_Boundary result = null; float num = 999999f; ListView <Moba_Camera_Boundary> .Enumerator enumerator = Moba_Camera_Boundaries.cube_boundaries.GetEnumerator(); while (enumerator.MoveNext()) { Moba_Camera_Boundary current = enumerator.get_Current(); if (!(current == null)) { if (current.isActive) { BoxCollider component = current.GetComponent <BoxCollider>(); Vector3 closestPointOnSurfaceBox = Moba_Camera_Boundaries.getClosestPointOnSurfaceBox(component, point); float magnitude = (point - closestPointOnSurfaceBox).magnitude; if (magnitude < num) { result = current; num = magnitude; } } } } ListView <Moba_Camera_Boundary> .Enumerator enumerator2 = Moba_Camera_Boundaries.sphere_boundaries.GetEnumerator(); while (enumerator2.MoveNext()) { Moba_Camera_Boundary current2 = enumerator2.get_Current(); if (current2.isActive) { SphereCollider component2 = current2.GetComponent <SphereCollider>(); Vector3 vector = current2.transform.position + component2.center; float radius = component2.radius; Vector3 b = vector + (point - vector).normalized * radius; float magnitude2 = (point - b).magnitude; if (magnitude2 < num) { result = current2; num = magnitude2; } } } return(result); }