I just duplicated a scene.
Then I duplicated the asset of the terrain that was in that scene.
Then I opened the duplicated scene and replaced the terrain data reference with the duplicated one.
But the terrains in the two scenes keep behaving like instanced from the same asset.
If I change a texture in one scene, the terrain on the other scene reflects the same changes.
That’s pretty odd.
Nobody ever tried to duplicate a terrain on another map???
I know this is an old thread and you’ve probably given up due to the complete lack of response, but I’m bumping this with a bit of explanation and because I also would like someone to explain what the heck is going on.
As far as I can tell:
When you create a new scene and create a terrain, a file is created named “New Terrain”.
Since it’s in the project folder, you would think you could treat it like any other asset - wrong…
If you select the terrain in the hierarchy and duplicate it, you don’t get a unique object, or even a prefab, at least not in the way prefabs are normally handled.
If you select each terrain and look at it in the inspector, you will see a link in the “Terrain Collider” section that points to “New Terrain” and “New Terrain 1”, respectively.
“Okay, cool.” you say to yourself, “Since there are now two “New Terrains” in the project folder, they must be individual assets”. Um, wrong again. Move the two terrains so they are side-by-side and edit one. You’ll see the changes reflected in both of them.
“What’s going on here?!”, you now shout to no one in particular. “I can see two assets, why do they behave as one?”
The answer is that they are not “standard” assets. Notice the icon in front of them. It isn’t a prefab icon, or object, or script, etc. It is it’s own unique icon that just represents some kind of file that we don’t have any access to. It functions similar to a prefab, but the original is completely inaccessible to the user.
Interestingly, if you select that “New Terrain 1” in the project folder and delete it, both terrains will still be editable as before. If you now go back and also delete “New Terrain” from the project view, both terrains will become invisible in the scene window, but are still in the hierarchy. If you then select one of the terrains in the hierarchy, in the inspector there will be a new box that says “Terrain Asset Missing” and there will be a box to reassign it. This does not appear until after the “New Terrain” asset is deleted.
“Okay,” you say again, thinking you are getting somewhere. “So that implies that I should be able to drag-and-drop any other “New Terrain” thingie whatchamabobber from the project window and it will all work again.”
Nope! Not happening. Once that link is destroyed, that’s it. You can create a new third terrain, assign the new “New Terrain” to the old terrains, but it isn’t visible and won’t work.
What this means:
If you are like me and you have a level all set up and would like to make more based on the current level and you’re thinking, “I’ll just do ‘Save scene as…’ and then make the changes I want to the new scene”, you’re out-of-luck. It ain’t happening. The people at Unity want you to create a completely new and unique terrain, starting from scratch each and every time you start a new scene. There is a workaround, sort of, but it’s also a pain:
- Select the terrain you want to duplicate.
- In the inspector, select the “Terrain Settings” tab (The one that looks like a gear all the way to the right in the Terrain(Script) section).
- Click on “Export Raw…” and set the export settings. This will save out a terrain.raw file.
- Go to your new scene and create a new terrain, making sure that all the resolution settings are exactly the same.
- In the Terrain Settings tab again, click “Import Raw…” and select that file. You will have to manually make sure that all the settings are correct (they won’t be by default. they reset every time.)
if everything goes right, you will now have an actual independent copy of your terrain height.
Notice I say the terrain height. As far as getting the texture work from one to the other: as far as I can tell, still not happening. If you painted your original terrain, there will be a listing under the “New Terrain” asset for “SplatAlpha 0”, etc. There doesn’t appear any way to access those or attach them to the new terrains, so you still end up basically starting from scratch. Even if you try to export the terrain as an asset and then import it into a new scene, any editing on the new terrain will STILL mess up the original in the original scene.
So…
Um, okay, so when I find stuff like this I usually try to remember that there is more than one way to do things and that there must be a good reason for the way it’s done. I also freely admit that a lot of times it’s just me that doesn’t understand things and I’m missing something obvious, and the moment I start complaining is the moment I suddenly figure it out and look really stupid.
Please Unity, make me look stupid! Prove to me that this is actually easy and that I’m just a jerk for complaining. I’ll take the hit if it solves the problem for people. I’ll do the tutorial and post it myself if it’ll help others avoid the amount of work I’ve wasted. There is no explanation or mention of this whatsoever that I can find in the manual (at least I couldn’t find it). It only explains how to create a new terrain, not what to do if you want to duplicate one. Searching the forums is also useless. Try doing a search for “Duplicate terrain” and see how many threads you get.)
This is a system that at it’s very core is set up so that people will fail horribly unless someone points it out to them. The end user’s first instinct will always be to use “Save Scene As” and then start editing the terrain in their new scene, thinking they now have two separate terrains. If they are LUCKY, they will switch back to their old scene right away and notice that it’s now completely messed up. How many people will actually catch that though, and how many hours have been wasted by people who have done this multiple times without noticing?
Not cool, and completely, utterly, unequivocally unacceptable. (Get the idea of what I’m trying to say here?)
If there is some serious reason why you have to do it this way, then there should be an option in the terrain menu for “Duplicate Terrain” or “Export Terrain” that does everything correctly. At the very, very least, you need to add a warning that pops up when the user selects the “Save Scene As” option that says: “Would you like to save the terrain as an independent asset without connection to the current scene?”, or failing all else, “Warning: Saving this scene under a new name will not create a new terrain! Any terrain edits made in the new scene will also be reflected in this one”.
If you’re still reading this, let’s hear how many of you have had this cause you problems. I’ve read threads about this before and I’m sure I’m not alone. Or am I?
It’s a good question, and one I have no answer to, but I can offer a solution.
In my Terrain Slicing Dynamic Loading Kit, I offer a tool which allows you to duplicate one or more terrains in a scene, so that each one is unique. The kit was just recently re-priced at $45, so if you’re just looking for the duplicator, I doubt you’ll want to buy it, but the kit does offer a lot of great stuff for terrains and game objects in general (handy tool that allows you to easily create prefabs). More info can be found here and here. Note that the dynamic loading portion of the kit is most incompatible with Unity 4.3 at the moment, as Unity introduced a bug that I cannot fix (though I am trying).
I will also probably release portions of this kit as standalone tools/mini-kits for much cheaper. Perhaps a 5$ terrain utility pack for instance.
In the mean time, if you want to make the tool yourself, try using the AssetDatabase.CopyAsset method. You can use it to create a unique copy of the TerrainData asset, then use that new asset to create a Terrain. It might not be necessary, but I also advise using AssetDatabase.Refresh() after copying the asset, and Terrain.Flush() after creating the terrain (and renaming it/moving it to its correct position). Good luck!