Terrain Texture Black on Android

Now that terrain is supported on Unity android, I’ve been working on a project. When I manually created my terrain, everything worked perfect both on computer and android.

I switched to dynamically generated terrain, and populated the terrain with splatPrototypes. It works perfectly on the computer, but on android the terrain is simply solid black. I am thinking perhaps this has to do with not having a Basemap texture? I can’t seem to find a way to apply it in the code. Or maybe there is some other issue that I am missing. Any suggestions would be welcome.

I have included the section of code where I attach the textures:

// add terrain textures

var splats = new SplatPrototype[1];
	splats[0] = new SplatPrototype();
	splats[0].texture = Resources.Load("grass");
	splats[0].tileSize = new Vector2(15,15);
	splats[0].tileOffset = new Vector2(0,0);

myTerrainData.splatPrototypes = splats;
var myTerrain = Terrain.CreateTerrainGameObject(myTerrainData);
myTerrain.transform.Translate(-terrainRes/2,0,-terrainRes/2);

I’ve tried using EDT texture compression instead of the default but that hasn’t helped.

2 Answers

2

Well this isn’t exactly a solution so much as a workaround, but I ended up placing a terrain object into the scene manually which had the texture on it. When it is present, the dynamically created terrain then has the texture also.

I just keep my manually created terrain in the scene but give it minimum size and place it below the new terrain.

Thank you for posting this work around. I was having the exact same problem, except for on a PC build. I am creating and texturing my terrain through a script. Everything would work perfectly fine when I would play the game from the editor. However, when I would build the game and play it, the terrain and terrain details would be completely black. Adding a single terriain manually, and giving it a texture and a detail grass with texture fixed it all for me.

My solution was to change Texture import settings to Advanced with “Read/Write” enabled. That forces unity to include texture even when its not used at start of game.