public void DrawTextureGrid(Rect canvasRect, float zoom, Vector2 pan = default) { Texture texture = EditorTools.CreateGridTexture(10, 10); var size = canvasRect.size; var center = size / 2f; float xOffset = -(canvasRect.x * zoom + pan.x) / texture.width; float yOffset = ((canvasRect.y - size.y) * zoom + pan.y) / texture.height; Vector2 tileOffset = new Vector2(xOffset, yOffset); float tileAmountX = Mathf.Round(size.x * zoom) / texture.width; float tileAmountY = Mathf.Round(size.y * zoom) / texture.height; Vector2 tileAmount = new Vector2(tileAmountX, tileAmountY); GUI.DrawTextureWithTexCoords(canvasRect, texture, new Rect(tileOffset, tileAmount)); }