函数:go//游戏对象,time//消失时间
protected void FadeAway(GameObject go, float time)
{
Transform[] transforms = go.GetComponentsInChildren<Transform>();
foreach (var transformChild in transforms)
{
Image image = transformChild.gameObject.GetComponent<Image>();
if (image)
{
image.color = new Color(255, 255, 255, 3f);
image.DOFade(0, time);
}
Text text = transformChild.gameObject.GetComponent<Text>();
if (text)
{
text.color = new Color(text.color.r, text.color.g, text.color.b, 3f);
text.DOFade(0, time);
}
}
}
调用:
FadeAway(AnswerTruePanel, 2f);