Hi,
I’ve been reading many of the posts here about how to change the texture that’s applied to a terrain, and it seems you can’t (for now, anyway). I was wondering if there are any workarounds for this.
For the project I’m working on, I’d like to display a basemap texture on a terrain and have ‘layers’ appear/disappear on top of that base texture when the user clicks a button. Like if you’re looking at a map from above, and want to show / hide roads, friendly / enemy territory, etc, with the new layers conforming to the topography of the terrain. Applying the basemap texture to the terrain is straightforward enough, but I’m having trouble figuring out how to implement the ‘layers’.
I’ve thought through several different approaches to doing this, but none that I’ve come up with are much help if you can’t change/add/delete the terrain’s texture through scripting in the first place.
I’ve started thinking about having the same terrain represented in different layers or scenes in Unity, each with a different texture, but I don’t know if this is even possible, let alone the right way to go about it.
Sorry if this has been covered in another post. Any help would be much appreciated!
Try to duplicate your terrain, deactivate it (after changing texture)
and create a trigger that deactivate the old terrain and activates the new. 
Thanks for the suggestion, Gaston. I’ve been looking into it, and I’m not sure how I could do this. The Terrain object doesn’t have a Renderer like other objects, so I can’t just set:
“terrain that I’d like to hide”.renderer.enabled = false
… unless I’m missing something.
Also, I’ve found that by toggling the lightmap on and off (I don’t need a lightmap for my base map), I can actually achieve what I’m after, but only for one additional layer (like if I want to turn a static grid on/off).
So now I’m wondering if there’s a way to access a Terrain’s lightmap through a script (ie beyond just toggling on/off). Also, I’ve come across this post:
http://forum.unity3d.com/viewtopic.php?t=7952&highlight=multiple+lightmaps
where there’s a bit of a tangent discussion about ‘blending multiple lightmaps at runtime’ and assigning the lightmap to the terrain. I’m kind of new to scripting, so I don’t understand how to go about blending the lightmaps, or how I might access individual lightmaps (after blending) through a script.
Any thoughts would be much appreciated!
Thanks!
(I’m without Unity currently, so I can’t test any of this on my own.)
Have you tried deforming a plane’s mesh to match the terrain? Use one plane per set of data. Modify the texture on the plane to represent the data and then use a cut-off transparency shader on each plane. You could then turn the renderer on and off on any of the planes.
Edit: Or, if you can edit the splatmap at run time, you could put the textures for the properties you want to display in the terrain’s textures. To highlight/exclude something you would just need to modify the splatmap.
Thanks for the reply, careyagimon. I don’t think it’s possible to modify the terrain’s splatmap at runtime (but please correct me if I’m wrong!).
As for deforming a planar mesh, I like that idea a lot. I saw that a few people were discussing something similar here:
http://forum.unity3d.com/viewtopic.php?t=8167
using Terrain.SampleHeight to determine how the plane should be deformed. This might be a real n00b question (sorry if it is), but how do I deform the mesh using the info from Terrain.SampleHeight? Info about scripting Planes in the Script Reference doesn’t say very much.
Once I get that figured out, I’ll give it a go. One problem that might pop up is that my terrain is pretty big, and generating that many polys for the plane at runtime might prove costly (in terms of time to generate and memory). But it’s very possible that I don’t know what I’m talking about. 
I don’t know exactly how you would want to do it, but the procedural content examples project has some mesh deformation scripts in it that might point you in the right direction. Procedural Examples | Tutorial Projects | Unity Asset Store
Cool, thanks! I’ll check that out.
Also, to clarify my original post, the map overlays that I have in mind (grids, territories, etc) are all static, so I don’t necessarily have to worry about updating the content in a given overlay on the fly.
I’m not giving up just yet on the possibility that using a ‘blended lightmap’ might also solve the problem, as per my post above. If anyone has any ideas about this or other methods that might solve the problem, I’m all ears!
Thanks.