- Home /
Web Player Primitive Color Issue
As the title says I'm having an issue with color on a primitive cube in the web player. My code builds the primitive at runtime. When the code runs in the Editor the cube takes the correct color of Color.white
but when I build to the web player and run it the cube takes a magenta color. I don't have magenta anywhere in my code. The cube is using a shader of unlit/texture. Anyone know why this is happening?
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.AddComponent<CubeScript>();
cube.renderer.material.shader = Shader.Find("Unlit/Texture");
cube.renderer.material.color = Color.white;
Answer by Eric5h5 · Nov 17, 2014 at 05:17 PM
The "magenta color" indicates a missing material. Make sure the Unlit/Texture shader is included in the build; an easy way is to make a material using this shader and put it in Resources. (Since everything in Resources is always included in a build.)
Worked perfectly. Just added a material to the Resources folder with the shader I'm using and set that to the material of the primitive. Piece of cake. Whats weird is that I couldn't find anything on Google about this issue because its a pretty simple solution.
Your answer
Follow this Question
Related Questions
Use of Unity Web Player Templates 1 Answer
Web Player: DynamicHeapAllocator out of memory 1 Answer
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Logo image in Facebook Canvas increases loading time. 0 Answers
Possible to change white iframe flash when navigating away from a web player page? 1 Answer