Skip to content

Commit 368e1bd

Browse files
author
setchi
committed
Speed up grid line renderer
1 parent 3586b97 commit 368e1bd

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Assets/Scripts/GLDrawing/GridLineRenderer.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ void Awake()
8888
}
8989

9090

91-
// Highlighting closest line to mouse pointer
92-
if (NoteCanvas.IsMouseOverNotesRegion.Value)
91+
// Highlighting closest line to mouse pointer
92+
if (NoteCanvas.IsMouseOverNotesRegion.Value)
9393
{
9494
var mouseX = Input.mousePosition.x;
9595
var closestLineIndex = GetClosestLineIndex(beatLines, c => Mathf.Abs(c.start.x - mouseX));
@@ -119,7 +119,15 @@ void Awake()
119119
}
120120
}
121121

122-
GLLineDrawer.Draw(beatLines);
122+
var screenWidth = Screen.width;
123+
for (int i = 0, l = beatLines.Length; i < l && beatLines[i].start.x < screenWidth; i++)
124+
{
125+
if (beatLines[i].start.x > 0)
126+
{
127+
GLLineDrawer.Draw(beatLines[i]);
128+
}
129+
}
130+
123131
GLLineDrawer.Draw(blockLines);
124132
});
125133
}

0 commit comments

Comments
 (0)