- Home /
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.
A bit of an update: I manually placed a terrain with the texture on it into my scene. When I loaded it again, both the manually placed terrain and the dynamically placed were textured. Could it be that the texture is not being included in the resources since it hasn't been attached to anything? How would I fix this?
However, when I placed a simple cube into the scene with the grass texture, that did not place the texture on the terrain also. I am very confused here.
Answer by thenelson · Sep 30, 2011 at 01:59 AM
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.
As of 03/03/2016 this is still a problem. I dynamically generate new terrain and texture prototypes, and when exporting and executing a build, the textures are missing and the terrain is black. What confuses me is all of the textures are referenced through script, but they still fail to be exported or load.
$$anonymous$$anually creating a terrain and $$anonymous$$ANUALLY adding the textures solved this problem for me. I tried to load the textures onto the manually created terrain through script and after building it looked like Bill Cosby's sweater, so even worse than plain black. It's a shame that this workaround is still needed because it's wasted overhead and an extra step when adding any other textures to the dynamic terrain. Very disappointing that this is still an issue.
Answer by Arcoder · Mar 02, 2015 at 03:08 AM
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.
Your answer
Follow this Question
Related Questions
Texture problem android 0 Answers
Odd Ground ( terrain ) texture appearance 0 Answers
Terrain Texture Problem 0 Answers
Unity Terrain texture issue on android device 1 Answer
Incorporating Unity textures, models, and terrain into Eclipse 0 Answers