我在脚本中写了给人物头部添加红色射线的代码,但是红色射线可以在scene窗口中看到,game窗口中看不到红色射线,这是怎么回事呢?
代码如下:
//头顶射线
RaycastHit2D headCheck = Raycast(new Vector2(0f, coll.size.y), Vector2.up, headClearance, groundLayer);
RaycastHit2D Raycast(Vector2 offset, Vector2 rayDiraction, float length, LayerMask layer)
{
Vector2 pos = transform.position;
RaycastHit2D hit = Physics2D.Raycast(pos + offset, rayDiraction, length, layer);
Color color = hit? Color.red : Color.green;
Debug.DrawRay(pos + offset, rayDiraction * length,color);
return hit;
}