Shader not visible when built

I have a simple 2D game with one simple Prefab as “tile”. When I start the game in the Editor it works fine, everything is rendered. When I build on my windows 7 or win 10 maschine for standalone Win or Android all works fine. However when I trigger the build via gitlab CI in the result the tiles are not rendered only the text canvas element which is a child element of the “tile”.

I use Unity Version 2018.2.3f1. The Docker Image I use is from here: GameCI / unity3d-gitlab-ci-example · GitLab

I added the shader to the ‘Always Included Shaders’ list. I tried “Unlit/Color”, “Standard” and the “Legacy/Specular” shader. None of them work.

When I get the shader from the material of the Gameobject it is the correct shader and the isSupported property is true. When I remove the shader from the ‘Always Included Shaders’ list the game crashes when creating the Material programmatically since the shader is not found.

Even if I don’t create the Material on the fly it is not working.

My Code for creating the Material:

Renderer rend = this.Tile.GetComponent<Renderer>();
rend.material = new Material(Shader.Find("Unlit/Color"));
rend.material.color = color;

So my question is: What can I do the properly render my “tiles”? For what debug/build output do I have to look?

1 Like

If untiy will not find any reference to a shader at buildtime in your scene or in one of the used asset it will remove any unused shader.
To make sure that unity will include the shader you are loading at runtime your can go into the Graphics settings add add the unlit color shader to the always include shaders list.

2 Likes

I have done that, this avoids the error that the script won’t find the shader, however it does not get rendered anyway. (Not even in pink)

I added an Cube from Unity to the scene which is getting rendered. So i tried to take the same material for the MeshRenderer from the Cube for the Tile but the tile, which was created in blender, does not get rendered.

The issue was that there was no blender installed in the docker container

2 Likes