Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Can I duplicate a terrain?

Discussion in 'Editor & General Support' started by Marscaleb, Dec 2, 2023.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,027
    I have made a terrain that is shared between multiple scenes simply by having a scene with a terrain and saving it as a new scene. This is quite handy because I can copy the exact terrain and any changes I make to it are automatically reflected in my other scenes.

    But now I'm working on a scene that I just want to be similar to the other terrains, not an exact copy. If I save a scene as a new scene and start editing the terrain, I've changed the terrain in all those other levels, too.
    But in this case I don't want that; I just want to start off with the same properties, have the same layers set up, and some of the same geometry. It would be a huge hassle to try to craft a brand new terrain that nearly-matches my other one.
    Is there any way I can "duplicate" my terrain and have it be a new terrain that won't impact my other one?

    I tried just duplicating the terrain object in the hierarchy, but both copies are still using the same data and if I edit one it changes the other. The only connection I can find to the terrain asset is the collider.
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,298
    This is a failing of the Terrain component's custom drawer. It does not work with Prefab overrides.

    The Terrain component has no visible link to the Terrain Data asset where you can change which data is being used (such as in a Prefab Override), unlike the Terrain Collider component. If you try to turn your object into a Prefab, then try to override which Terrain Data asset is being used in the Terrain Collider, the actual Terrain component immediately warns of the mis-match and "helpfully" forces the Terrain Collider's field back (when you really would prefer the reverse).
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,338
    You can get a long way towards duplicating a terrain this way:

    - make the terrain and use it in scene #1

    - select the terrain asset (in the project) and duplicate it

    - make a new blank scene (scene #2)

    - drag the duplicated terrain asset into the scene

    - now edit this terrain #2 in scene #2

    Over the years this has worked to one extent or another, but I haven't tried it with the newest layer-based terrain system. It might be that some of your data is still linked to older stuff, or that you need to do extra work to dupe the layers and connect those.

    It's very annoying this limitation. It would be so easy to expose the terrain data.

    This is why it is helpful to use source control so you can confidently tell which files are being touched and then revert them if they aren't the ones you intended.