title: Generating a procedural tiled background
body: <p>I'm trying to build a Shmup game with a tiled background, where I would like to make it procedure generated in the future.
  But right now, I can't even make a static background. No matter what, I can't make the tiles fill the screen.</p>
  
  <p>I'm using a tile of 64x64 pixels.</p>
  
  <p>And here the code I'm using: </p>
  
  <pre><code>void Start()
  {
      m_screenHeight = 1408;
      m_screenWidht = Camera.main.aspect * m_screenHeight;
  
      float UnitsPerPixel = 1f / 100f;
  
      Camera.main.orthographicSize = m_screenHeight / 2f * UnitsPerPixel;
  
      m_horizontalTilesNumber = (int)Math.Floor(m_screenWidht / TileSize);
      m_verticalTilesNumber = (int)Math.Floor(m_screenHeight / TileSize);
  
      for (int i = 0; i &lt; m_horizontalTilesNumber; i++)
      {
          for (int j = 0; j &lt; m_verticalTilesNumber; j++)
          {
              Instantiate(Tile, Camera.main.ScreenToWorldPoint(new Vector3(TileSize * i, TileSize * j, 0)), Quaternion.identity);
          }
      }
  }
  </code></pre>
  
  <p>Here is what It look likes:</p>
  
  <p><img src="https://i.stack.imgur.com/MCjdG.png" alt="enter image description here"></p>
  
  <p>Seems to me that I'm having some problem converting my pixel coordinates to Units, or something like this.</p>
  
  <p>Any tips or directions here would be appreciated.</p>