Hello guys, i tried everything to instantiate a material into a clone of a prefab.
I tried to attach a script into a Car Prefab who can randomize colors, in each cloned prefab i need to put a new material or a temporary material with one color each.
I tried to change the material who references the prefab but all the cars change to the same color in each start of my coroutine.
private void RandomCarColor(){
rlColor = carColor[randomColorNumber];
string shaderText =
"Shader \"Alpha Diffuse\" {" +
"Properties { _Color (\"Main Color\", Color) = (1,1,1,0) }" +
"SubShader {" +
" Tags { \"Queue\" = \"Transparent\" }" +
" Pass {" +
" Blend One One ZWrite Off ColorMask RGB" +
" Material { Diffuse [_Color] Ambient [_Color] }" +
" Lighting On" +
" SetTexture [_Dummy] { combine primary double, primary }" +
" }" +
"}" +
"}";
renderer.material = new Material( shaderText );
renderer.material.color = rlColor;
clonedMaterial.color = rlColor;
What help i need:
How to, assign a temporary material for each instance i spawn from this original car object.
I can saw the new material(Instantiated) in the inspector but it not assigned the color cars dont change for a unique color each one.
Someone can help? Thanks.