private void OnDrawGizmos() { if (!visible && Application.IsPlaying(gameObject)) { return; } Vector3 boxSize = EffectiveUtility.VectorMultiple(guideSize, Isometric.IsometricTileSize); Vector3[] box = new Vector3[] { transform.parent.position + EffectiveUtility.VectorMultiple(new Vector3(-0.5f, 1f, 0.5f), boxSize), transform.parent.position + EffectiveUtility.VectorMultiple(new Vector3(-0.5f, 1f, -0.5f), boxSize), transform.parent.position + EffectiveUtility.VectorMultiple(new Vector3(0.5f, 1f, -0.5f), boxSize), transform.parent.position + EffectiveUtility.VectorMultiple(new Vector3(0.5f, 1f, 0.5f), boxSize), transform.parent.position + EffectiveUtility.VectorMultiple(new Vector3(-0.5f, 0f, -0.5f), boxSize), transform.parent.position + EffectiveUtility.VectorMultiple(new Vector3(0.5f, 0f, -0.5f), boxSize), transform.parent.position + EffectiveUtility.VectorMultiple(new Vector3(0.5f, 0f, 0.5f), boxSize) }; Gizmos.color = new Color(0.1f, 0.9f, 0.1f); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[0]), Isometric.TranslationIsometricToScreen(box[1])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[1]), Isometric.TranslationIsometricToScreen(box[2])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[2]), Isometric.TranslationIsometricToScreen(box[3])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[3]), Isometric.TranslationIsometricToScreen(box[0])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[1]), Isometric.TranslationIsometricToScreen(box[4])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[2]), Isometric.TranslationIsometricToScreen(box[5])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[3]), Isometric.TranslationIsometricToScreen(box[6])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[4]), Isometric.TranslationIsometricToScreen(box[5])); Gizmos.DrawLine(Isometric.TranslationIsometricToScreen(box[5]), Isometric.TranslationIsometricToScreen(box[6])); Gizmos.color = Color.white; }
private void OnPostRender() { if (!lineMat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.Begin(GL.LINES); lineMat.SetPass(0); Vector3 currentCameraCenterTilePos = Isometric.GetOwnedTilePos( Isometric.GetIsometicBasePositionByWorldRay(Camera.main.transform.position, Camera.main.transform.forward)); Vector3 currentMouseTilePos = Isometric.GetOwnedTilePos( Isometric.GetIsometicBasePositionByWorldRay(Camera.main.ScreenToWorldPoint(Input.mousePosition), Camera.main.transform.forward)); if (activateGrid) { GL.Color(Color.white); for (int x = -10; x < 10; ++x) { Vector3 left = new Vector3((x + 0.5f) * Isometric.IsometricTileSize.x, 0f , -9.5f * Isometric.IsometricTileSize.z), right = new Vector3((x + 0.5f) * Isometric.IsometricTileSize.x, 0f, 9.5f * Isometric.IsometricTileSize.z); GL.Vertex(Isometric.TranslationIsometricToScreen(left + currentCameraCenterTilePos)); GL.Vertex(Isometric.TranslationIsometricToScreen(right + currentCameraCenterTilePos)); } for (int z = -10; z < 10; ++z) { Vector3 down = new Vector3(-9.5f * Isometric.IsometricTileSize.x, 0f, (z + 0.5f) * Isometric.IsometricTileSize.z), top = new Vector3(9.5f * Isometric.IsometricTileSize.x, 0f, (z + 0.5f) * Isometric.IsometricTileSize.z); GL.Vertex(Isometric.TranslationIsometricToScreen(down + currentCameraCenterTilePos)); GL.Vertex(Isometric.TranslationIsometricToScreen(top + currentCameraCenterTilePos)); } } if (activateHoverGuideLine) { GL.Color(Color.red); Vector3 leftBottom = currentMouseTilePos - 0.5f * new Vector3(Isometric.IsometricTileSize.x, 0f, Isometric.IsometricTileSize.z);; Vector3 leftTop = currentMouseTilePos + 0.5f * new Vector3(-Isometric.IsometricTileSize.x, 0f, Isometric.IsometricTileSize.z); Vector3 rightBottom = currentMouseTilePos + 0.5f * new Vector3(Isometric.IsometricTileSize.x, 0f, -Isometric.IsometricTileSize.z); Vector3 rightTop = currentMouseTilePos + 0.5f * new Vector3(Isometric.IsometricTileSize.x, 0f, Isometric.IsometricTileSize.z);; GL.Vertex(Isometric.TranslationIsometricToScreen(leftBottom)); GL.Vertex(Isometric.TranslationIsometricToScreen(leftTop)); GL.Vertex(Isometric.TranslationIsometricToScreen(leftBottom)); GL.Vertex(Isometric.TranslationIsometricToScreen(rightBottom)); GL.Vertex(Isometric.TranslationIsometricToScreen(leftTop)); GL.Vertex(Isometric.TranslationIsometricToScreen(rightTop)); GL.Vertex(Isometric.TranslationIsometricToScreen(rightBottom)); GL.Vertex(Isometric.TranslationIsometricToScreen(rightTop)); } GL.End(); }