fix: Physics.RaycastAll扫全部命中—Ground阻挡也不影响鞋子点击
This commit is contained in:
@@ -18,7 +18,7 @@ public class ShoseClickHandler : MonoBehaviour
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(BlinkOutline());
|
||||
_clicked = false;
|
||||
Debug.Log($"[ShoseClick] OnEnable outline={_outlineMesh!=null} col={(col is SphereCollider sc2?sc2.radius:-1)}");
|
||||
Debug.Log($"[ShoseClick] OnEnable outline={_outlineMesh!=null} col={((SphereCollider)col).radius}");
|
||||
}
|
||||
|
||||
void CreateOutlineMesh()
|
||||
@@ -44,11 +44,7 @@ public class ShoseClickHandler : MonoBehaviour
|
||||
{
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = true;
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
while (true)
|
||||
{
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = !_outlineMesh.enabled;
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
}
|
||||
while (true) { if (_outlineMesh != null) _outlineMesh.enabled = !_outlineMesh.enabled; yield return new WaitForSeconds(0.4f); }
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -57,11 +53,13 @@ public class ShoseClickHandler : MonoBehaviour
|
||||
foreach (var cam in Camera.allCameras)
|
||||
{
|
||||
if (!cam.enabled) continue;
|
||||
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, 100f) && hit.collider != null && hit.collider.gameObject == gameObject)
|
||||
var hits = Physics.RaycastAll(cam.ScreenPointToRay(Input.mousePosition), 100f);
|
||||
foreach (var h in hits)
|
||||
{
|
||||
OnClicked();
|
||||
return;
|
||||
if (h.collider != null && h.collider.gameObject == gameObject)
|
||||
{
|
||||
OnClicked(); return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,8 +70,7 @@ public class ShoseClickHandler : MonoBehaviour
|
||||
Debug.Log("[ShoseClick] ★ 被点击了 ★");
|
||||
StopAllCoroutines();
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = false;
|
||||
if (targetPoint != null) { transform.position = targetPoint.position; transform.rotation = targetPoint.rotation; Debug.Log($"[ShoseClick] 移动到 {targetPoint.name}"); }
|
||||
else Debug.LogWarning("[ShoseClick] targetPoint 为空");
|
||||
if (targetPoint != null) { transform.position = targetPoint.position; transform.rotation = targetPoint.rotation; }
|
||||
if (nextObject != null) nextObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user