-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrossLinesMarker.cs
More file actions
44 lines (35 loc) · 1.28 KB
/
CrossLinesMarker.cs
File metadata and controls
44 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using UnityEngine;
namespace com.github.lhervier.ksp {
public class CrossLinesMarker {
private readonly Vector2 center;
private readonly Color color;
public CrossLinesMarker(Vector2 center, Color color) {
this.center = center;
this.color = color;
}
public void Draw() {
// Get the screen dimensions
float screenWidth = Screen.width;
float screenHeight = Screen.height;
// Horizontal line (from left to right of the screen)
DrawLine(
new Vector2(0, center.y),
new Vector2(screenWidth, center.y),
color
);
// Vertical line (from top to bottom of the screen)
DrawLine(
new Vector2(center.x, 0),
new Vector2(center.x, screenHeight),
color
);
}
private void DrawLine(Vector2 start, Vector2 end, Color color) {
GL.Begin(GL.LINES);
GL.Color(color);
GL.Vertex3(start.x, start.y, 0);
GL.Vertex3(end.x, end.y, 0);
GL.End();
}
}
}