void UpdateColor() { if (Color.from == Color.to) { return; } for (int i = 0; i < renderers.Length; i++) { if (renderers[i] == null) { continue; } TextMesh tm = renderers[i].GetComponent <TextMesh>(); Color newColor = new Color(); if (tm) { newColor = Color.from + easeValue * (Color.to - Color.from); PYTextBox tmb = tm.GetComponent <PYTextBox>(); if (tmb != null) { tmb.Color = newColor; } else { tm.color = newColor; } } else if (renderers[i] is SpriteRenderer) { SpriteRenderer render = (SpriteRenderer)renderers[i]; newColor = render.color; newColor = Color.from + easeValue * (Color.to - Color.from); render.color = newColor; } else if (renderers[i].sharedMaterial.HasProperty(colorProperty)) { newColor = Color.from + easeValue * (Color.to - Color.from); renderers[i].sharedMaterial.SetColor(colorProperty, newColor); } } if (images == null) { return; } for (int j = 0; j < images.Length; j++) { images[j].color = Color.from + easeValue * (Color.to - Color.from); } }
void UpdateAlpha() { if (Alpha.from == Alpha.to) { return; } for (int i = 0; i < renderers.Length; i++) { if (renderers[i] == null) { continue; } TextMesh tm = renderers[i].GetComponent <TextMesh>(); Color newColor = new Color(); if (tm) { newColor = tm.color; newColor.a = Mathf.Clamp01(Alpha.from + easeValue * (Alpha.to - Alpha.from)); PYTextBox tmb = tm.GetComponent <PYTextBox>(); if (tmb != null) { tmb.Color = newColor; } else { tm.color = newColor; } } else if (renderers[i] is SpriteRenderer) { SpriteRenderer render = (SpriteRenderer)renderers[i]; newColor = render.color; newColor.a = Mathf.Clamp01(Alpha.from + easeValue * (Alpha.to - Alpha.from)); render.color = newColor; } //TODO: rever uso de shared materials else if (renderers[i].material == null) { continue; } else if (renderers[i].material.HasProperty(colorProperty)) { newColor = renderers[i].material.GetColor(colorProperty); newColor.a = Mathf.Clamp01(Alpha.from + easeValue * (Alpha.to - Alpha.from)); renderers[i].material.SetColor(colorProperty, newColor); } } if (images == null) { return; } for (int j = 0; j < images.Length; j++) { Color newColor = new Color(); newColor = images[j].color; newColor.a = Mathf.Clamp01(Alpha.from + easeValue * (Alpha.to - Alpha.from)); images[j].color = newColor; } }