Hello Guest

Author Topic: Prefab terrain 'chunks'  (Read 4023 times)

agkunz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Prefab terrain 'chunks'
« on: January 09, 2013, 09:20:29 pm »
Hello,

I'm trying to build a dynamic level.  The plan is to build short sections of terrain and gameobjects, save them as prefabs, and then randomly pick a few of them to render on the screen.
I've created a sample object containing two tilemaps and their renderdata, one for the terrain and one for the gameobjects.
When I drag my prefab back into the scene just to test, the gameobjects appear but the terrain does not.  I suspect this is because the gameobjects all have data attached to them whereas the terrain does not.  If I select the terrain tile map and click edit, the terrain appears.  If I click commit it, stays on the screen.  If I move the object around the gameobjects go with it but the terrain stays where it was on the screen until I click edit and commit again.

The root of the question, am I doing this right?  Is there a better way?  Is there a way to call the edit and commit buttons from code at run time?  Do I need to actually attach data to every tile in the terrain tilemap?

Thanks,
Adam.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Prefab terrain 'chunks'
« Reply #1 on: January 10, 2013, 01:03:46 am »
This isn't going to work properly for a few reasons. Also the overhead of spawning multiple of these is rather expensive.

While this could probably be tweaked to work, there is another approach which you can use which may or may not work in your use-case. In the tilemap settings page, click on "make serializable". This will let you save the renderdata into a folder somewhere. You will then be able to make a prefab of the Render Data object and spawn it in other scenes.

The downside to this is, it won't work with the platform feature.