- Home /
Wont Change Color
#pragma strict
public var cubeA : GameObject;
public var cubeB : GameObject;
public var cubeC : GameObject;
public var cubeD : GameObject;
function Start () {
var ranNmbr = Random.Range(0, 4);
switch(ranNmbr) {
case 0 :
cubeA.renderer.material.color = Color.black;
Debug.Log("A is Black");
break;
case 1 :
cubeB.renderer.material.color = Color.black;
Debug.Log("B is Black");
break;
case 2 :
cubeC.renderer.material.color = Color.black;
Debug.Log("C is Black");
break;
case 3 :
cubeD.renderer.material.color = Color.black;
Debug.Log("D is Black");
break;
}
}
for some reason it isnt changing my cubes color the 4 cubes are children of a epmtygameObject in which the code sits in i have dragged the 4 cubs in the respective spots in the inspector to match according the the public variables anyone know what im doing wrong ?
It works for me. Do you have something else that's changing the materials on those objects elsewhere?
And be sure to use a shader that supports changing color. $$anonymous$$ost "$$anonymous$$obile" shaders for example don't
i have a piece of code that changes the color when clicked but the code shoudlnt effect this at all ill post it f need be
figured it out the other code was changing the color to white from the start so it would chnage the color to black and then back to white lol THAN$$anonymous$$S though