public static void DrawTiles(Camera camera, LightTilemapRoom2D id, Material material) { Vector2 cameraPosition = -camera.transform.position; float cameraRadius = CameraTransform.GetRadius(camera); if (id.superTilemapEditor.tilemap == null) { return; } if (id.superTilemapEditor.tilemap.Tileset != null) { material.mainTexture = id.superTilemapEditor.tilemap.Tileset.AtlasTexture; } material.color = id.color; LightTilemapCollider.Base tilemapCollider = id.GetCurrentTilemap(); material.SetPass(0); GL.Begin(GL.QUADS); int count = id.superTilemapEditor.chunkManager.GetTiles(CameraTransform.GetWorldRect(camera)); for (int i = 0; i < count; i++) { LightingTile tile = id.superTilemapEditor.chunkManager.display[i]; Vector2 tilePosition = tile.GetWorldPosition(tilemapCollider); tilePosition += cameraPosition; if (tile.NotInRange(tilePosition, cameraRadius)) { continue; } Vector2 scale = tile.worldScale * 0.5f * tile.scale; Rendering.Universal.Texture.DrawPassSTE(tilePosition, scale, tile.uv, tile.worldRotation, 0); } GL.End(); material.mainTexture = null; material.color = Color.white; }
static public void Grid(Light2D light, LightTilemapCollider2D id) { Vector2 lightPosition = -light.transform.position; LightTilemapCollider.Base tilemapCollider = id.GetCurrentTilemap(); int count = tilemapCollider.chunkManager.GetTiles(light.GetWorldRect()); for (int i = 0; i < count; i++) { LightingTile tile = tilemapCollider.chunkManager.display[i]; List <Polygon2> polygons = tile.GetWorldPolygons(tilemapCollider); Vector2 tilePosition = tile.GetWorldPosition(tilemapCollider); if (tile.NotInRange(tilePosition + lightPosition, light.size)) { continue; } Rendering.Light.ShadowEngine.Draw(polygons, 0, 0); } }