I'm trying to change the alpha/transparency of all clones of the prefab. The transparency of the prefab itself changes correctly, but when I put multiple clones of the same prefab in the scene only one clone changes. The prefab is a sprite and the alpha is changed when a key is pressed in the PlayerController:
//--TRANSPARENCY--//
if (PlayerController.toggleSpirit) {
if (!isLocked) {
isSpirit = !isSpirit;
}
PlayerController.toggleSpirit = false;
}
if (isSpirit) {
sr.color = new Color(1f, 1f, 1f, .5f);
} else if (isSpirit == false) {
sr.color = new Color(1f, 1f, 1f, 1f);
}
The sr.color is getting the SpriteRenderer Component.
↧