Skip to content

Commit 61b46c1

Browse files
committed
Fix for Issue jagt#7 - text visible when behind camera
2 parents ba64bb6 + c02e0e4 commit 61b46c1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: Assets/RuntimeDebugDraw.cs

+10
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,11 @@ private void DrawTextOnGUI()
813813
private void GUIDrawTextEntry(Camera camera, DrawTextEntry entry)
814814
{
815815
Vector3 worldPos = entry.anchor;
816+
Vector3 heading = worldPos - camera.transform.position;
817+
if (Vector3.Dot(camera.transform.forward, heading) <= camera.nearClipPlane)
818+
{
819+
return;
820+
}
816821
Vector3 screenPos = camera.WorldToScreenPoint(worldPos);
817822
screenPos.y = Screen.height - screenPos.y;
818823

@@ -836,6 +841,11 @@ private void GUIAttachTextEntry(Camera camera, AttachTextEntry entry)
836841
return;
837842

838843
Vector3 worldPos = entry.transform.position + entry.offset;
844+
Vector3 heading = worldPos - camera.transform.position;
845+
if (Vector3.Dot(camera.transform.forward, heading) <= camera.nearClipPlane)
846+
{
847+
return;
848+
}
839849
Vector3 screenPos = camera.WorldToScreenPoint(worldPos);
840850
screenPos.y = Screen.height - screenPos.y;
841851

0 commit comments

Comments
 (0)