textures white/grey after build and run
i have a few images that i am using to texture some planes. The planes render perfectly fine in unity. but as soon as i build and run, they were initially all white. After some googling, i saw someone post something about materials, i changed my shader to "Legacy Shaders/Diffuse Detail" . Now i see some grey some white some brown planes instead (not the correct textures). i am also setting the scale as: mr.material.SetTextureScale("_MainTex", new Vector2(-1, 1));
images to show the issue: from build and run:
from unity:
i am not sure whats wrong. Any suggestions are welcome
Is you project working at all with any other textures on a standard plane or cube etc.?
I read somewhere that unity needs at least one material to render textures. I was generating everything via script file so i didnt have any materials manually created. So, i added a cube and created a material and assigned it red color. after building and running. it works!
now i have a red cube sitting in my app somewhere haha.
For which platform are you building your project?
Answer by Desoxi · Nov 10, 2016 at 12:53 PM
Hahaha yeah, great app indeed! :D
But yes, unity needs a material and a mesh renderer (like it is used in the cube you created) & a Mesh filter to actually render your object. The Mesh filter has a reference to the actual mesh with its vertices etc. The Mesh Renderer needs a reference to the material(s) you want to use. So you have to add the created material to the mesh renderer in the corresponding gameobject . If no renderer is present, just create one or add it to you prefab which you are instantiating.
I have the same issue and you did not understand the problem, which this issue cannot be reduced to $$anonymous$$esh Renderer-$$anonymous$$aterial reference, but everything is fine in the Unity (a ready game I prepared I can say) and almost all models are devoid of materials on Build.
I suspect a shader error which I had added Built-in Shaders and then removed them from the project and since that time this problem appears.
Answer by GermiyanBey · Dec 09, 2019 at 01:11 PM
I have the same issue after I added Built-in Shaders and then removed them from the project and Build and Run, and since that time this problem appears.
Thus I suspect a shader error instead of a simple Mesh Renderer-Material reference loss in contrary to the other suggestion here.
Answer by Sebas10PSG · Mar 19, 2020 at 10:25 AM
I had to enable the Read/Write on the sprite and it fixed it for me