void OnPostRender()
{
if (m_show == false) return;
GL.PushMatrix();
#if !UNITY_ANDROID
temp.SetPass(0);
#endif
// X-Y Plane.
Color c = m_currentGridColor;
float thickWidth = 1.5f;
float zVal = 0.15f;
if (m_camController.IsMirrored()) {
zVal *= -1.0f;
}
// draw horizontal lines
{
float xMin = -0.25f; float xMax = 0.25f;
float yMin = 0.0f; float yMax = 0.3f;
float increment = 0.01f;
int count = 0;
while (yMin <= yMax) {
Vector3 start = new Vector3(xMin, yMin, zVal) + m_center;
Vector3 end = new Vector3(xMax, yMin, zVal) + m_center;
if (count % 5 == 0) {
DrawLine(start, end, c, thickWidth);
} else {
DrawLine(start, end, c);
}
count++;
yMin += increment;
}
}
// vertical lines
{
float xMin = -0.25f; float xMax = 0.251f;
float yMin = 0.0f; float yMax = 0.3f;
float increment = 0.01f;
int count = 0;
while (xMin <= xMax) {
Vector3 start = new Vector3(xMin, yMin, zVal) + m_center;
Vector3 end = new Vector3(xMin, yMax, zVal) + m_center;
if (count % 5 == 0) {
DrawLine(start, end, c, thickWidth);
} else {
DrawLine(start, end, c);
}
count++;
xMin += increment;
}
}
// X-Z plane
{
float xMin = -0.25f; float xMax = 0.25f;
float zMin = -0.15f; float zMax = 0.15f;
float increment = 0.01f;
int count = 0;
while (zMin <= zMax) {
Vector3 start = new Vector3(xMin, 0, zMin) + m_center;
Vector3 end = new Vector3(xMax, 0, zMin) + m_center;
if (count % 5 == 0) {
DrawLine(start, end, c, thickWidth);
} else {
DrawLine(start, end, c);
}
count++;
zMin += increment;
}
}
{
float xMin = -0.25f; float xMax = 0.251f;
float zMin = -0.15f; float zMax = 0.15f;
float increment = 0.01f;
int count = 0;
while (xMin <= xMax) {
Vector3 start = new Vector3(xMin, 0, zMin) + m_center;
Vector3 end = new Vector3(xMin, 0, zMax) + m_center;
if (count % 5 == 0) {
DrawLine(start, end, c, thickWidth);
} else {
DrawLine(start, end, c);
}
count++;
xMin += increment;
}
}
GL.PopMatrix();
}