I want to apply a texture or a color on a game object. I wrote this code so far but the color part is not working. The texture is applied, so at least something is right. Depends of the type of the object i am applying a texture or a color, not both at the same time.
If i play the scene i can see a new material getting assign (i see it in the inspector panel) but with a white color.
GameObject o = GameObject.Find(items[i].name + "/" + ifv.field_details.name);
if (o != null){
if (ifv.field_details.type_id.Equals(Strings.colorType)){
//set the color
string[] c = ifv.value.Split(',');
Color color = new Color(float.Parse(c[1]),float.Parse(c[2]),float.Parse(c[3]),float.Parse(c[0]));
Material material = new Material(Shader.Find("Diffuse"));
material.color = color;
o.renderer.material = material;
}
if (ifv.field_details.type_id.Equals(Strings.textureType)){
//set the texture
string url = Strings.texturesHost + ifv.value;
WWW www = new WWW (url);
yield return www;
o.renderer.material.mainTexture = www.texture;
}
}
Any idea why the color if
statement is not working ?