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. Dismiss Notice

Copying Terrain Data

Discussion in 'Editor & General Support' started by demize2010, Feb 15, 2011.

  1. demize2010

    demize2010

    Joined:
    Feb 11, 2011
    Posts:
    24
    Hi guys, let me start of by saying how great Unity is!

    Currently prototyping a game design and the speed of development is simply amazing.

    I was wondering if anyone knew how to copy terrain data (not the asset) so you can use it as a starting block to build another bit of terrain data from?

    So in this example I want to take my square with a path on it, copy the data out and attach it to a new terrain asset and then build a little hill (without having to re do all the texture and grass work etc). This way when I build my hill, the original path asset will remain untouched.

    I appreciate this is stretching the limits of the terrain system - but surely there must be a way to duplicate those terrain data's in the project window?

    Thanks in advance!
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    You should be able to duplicate a terrain asset by selecting Edit > Duplicate with the asset selected. You will also notice that there are options to import and export heightmaps on the Terrain menu. This saves the shape of the terrain to a separate file which can then be used as the basis for other terrains (in different projects, say).
     
  3. demize2010

    demize2010

    Joined:
    Feb 11, 2011
    Posts:
    24
    ah thanks much andeeee, I was pretty sure it was me being daft.
     
  4. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    319
    I have a similar question, I have quite a lengthy pipeline for setting up my terrains, my scene contains 9 individual terrains.

    I want to be able to create a new scene using those terrains already setup but with different heightfields. There doesn't seem to be a way to associate a terrain asset with a terrain script object component. If I duplicate a terrain asset how is it associated with a terrain script ?

    This seems to occur when you first 'Create Terrain' which creates a game object with a terrain script and a terrain asset but as far as I can see there is no way to change the reference.
     
  5. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    This.
    Exactly what sh0v0r is asking for. How can we associate another terrain asset with a given terrain component? How can we switch terrain assets?
    Is there an in-editor-method? Or do we have to script this (pointing into the general direction should suffice)?

    Edit: nevermind. Found the necessary information in the scripting reference as there doesn't seem to be a method for associating terrain data directly inside the editor.
     
    Last edited: Aug 17, 2012
  6. mk1978

    mk1978

    Joined:
    Dec 27, 2009
    Posts:
    276
    Is it still so that there is no simple way (custom asset) to copy terrain data into another scene? I did quick search and all the discussions seem to be from 2010-2012 and there was not really simple solution. Below is link to one way to dublicate terrain data, but in this I was not able to copy the RTP terrain shader information at least.

    http://answers.unity3d.com/questions/58342/problem-with-terrain-duplicates-simple.html

    Basically I would like to be able to copy my current scene with terrain. Start modifying the new scene without affecting the other scene's terrain object. Now when I copy the scene and modify the terrain the old terrain gets modified also. In my case I am creating golf course and I would need to repeat this 18 times. This is the reason why I am looking for a simple solution.
     
  7. KABLAMM

    KABLAMM

    Joined:
    Jul 24, 2012
    Posts:
    8
    In case anyone is looking for an answer to this, if you duplicate the terrain asset in your file system (e.g. Windows Explorer) and rename it, you can then drag it into your hierarchy and it will have it's own copy of the terrain data. New changes won't affect the other terrains in other scenes.
     
  8. hunter_sk

    hunter_sk

    Joined:
    May 3, 2016
    Posts:
    6
    I think I figured it out. Terrain height data is stored with collision data in terrain asset. This asset must be linked to Collider component, and also to Terrain component. Link to Terrain Component is hidden and you should enable debug mode to assign it.

    So if you want to copy scene with terrain to make duplicate:
    - copy scene
    - copy terrain asset file
    - open copied scene
    - link terrain asset to terrain collider component
    - set inspector to debug mode
    - link terrain asset to terrain component
     
    borgstation, Endlesser and ONS49 like this.
  9. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Yes been here before. I remember having to do this in the debug mode but currently when I look at my Terrain in the Inspector I can see the Terrain Data without debug mode. I wonder if they have recently moved it to display in normal mode... I am using 2020.1.

    Point is, the Terrain data is in a separate asset called Terrain Data, and multiple Terrain objects can use the same data. When duplicating, one needs to make sure there is a new Terrain Data object, and the new Terrain is actually pointing to it, if this is the intention.