Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

rendering a tile repeatedly from script

Discussion in 'Scripting' started by mkandula, Jan 17, 2015.

  1. mkandula

    mkandula

    Joined:
    Oct 16, 2014
    Posts:
    16
    Hi

    I have created a tile mesh in the script and able to render it. Now I want to able to render a terrain using these tiles. I want to render the tiles based on camera view and I have the positions. How can I use this single tile mesh and render repeatedly from the script ?

    Thanks.
     
  2. TheForsaken95

    TheForsaken95

    Joined:
    Aug 29, 2014
    Posts:
    30
    I would use a 2D for loop.
    int width = 200;
    int height = 200;

    for(int x = 0; x < width; x++) {
    for(int y = 0; y < height; y++) {

    }
    }

    You could render a 200x200 landscape using a 2D for loop.
     
  3. mkandula

    mkandula

    Joined:
    Oct 16, 2014
    Posts:
    16
    I want to use a single gameobject which is the tile and render it in a loop. Which function should I call to render ? How do I set up the render call ?
     
  4. gamer_boy_81

    gamer_boy_81

    Joined:
    Jun 13, 2014
    Posts:
    169
    Do you mean you want to dynamically create tiles where the camera looks at ?
     
  5. mkandula

    mkandula

    Joined:
    Oct 16, 2014
    Posts:
    16
    I dont want to create multiple tiles. I want simply to render the tile I have created (once) and render it in a loop at different positions that form the terrain.
     
  6. gamer_boy_81

    gamer_boy_81

    Joined:
    Jun 13, 2014
    Posts:
    169
    Hmm..You say that you have created "the tile" which indicates that its a single tile
    and then you also want to render it "in a loop" ? Why would you need a loop to
    render a single tile ?