Update RayTool.cs
This commit is contained in:
@@ -39,7 +39,7 @@ namespace MuHua {
|
||||
/// <summary> 屏幕坐标转世界坐标 </summary>
|
||||
public static bool GetScreenToWorldPosition(Camera camera, Vector3 screen, out Vector3 position, LayerMask planeLayerMask) {
|
||||
Ray ray = camera.ScreenPointToRay(screen);
|
||||
Physics.Raycast(ray, out hitInfo, 200, planeLayerMask);
|
||||
Physics.Raycast(ray, out hitInfo, 500, planeLayerMask);
|
||||
position = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
|
||||
if (hitInfo.transform != null) { position = hitInfo.point; }
|
||||
return hitInfo.transform != null;
|
||||
@@ -77,7 +77,7 @@ namespace MuHua {
|
||||
/// <summary> 从屏幕坐标获取对象 </summary>
|
||||
public static bool GetScreenToWorldObject<T>(Camera camera, Vector3 screen, out T value, LayerMask planeLayerMask) where T : Object {
|
||||
Ray ray = camera.ScreenPointToRay(screen);
|
||||
Physics.Raycast(ray, out hitInfo, 200, planeLayerMask);
|
||||
Physics.Raycast(ray, out hitInfo, 500, planeLayerMask);
|
||||
value = hitInfo.transform?.GetComponent<T>();
|
||||
return value != null;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace MuHua {
|
||||
/// <summary> 从屏幕坐标获取碰撞信息 </summary>
|
||||
public static bool GetScreenToWorldHitInfo(Camera camera, Vector3 screen, out RaycastHit hitInfo, LayerMask planeLayerMask) {
|
||||
Ray ray = camera.ScreenPointToRay(screen);
|
||||
return Physics.Raycast(ray, out hitInfo, 200, planeLayerMask);
|
||||
return Physics.Raycast(ray, out hitInfo, 500, planeLayerMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user