所以基本上,当玩家触摸平台时,我希望使用unity3d将文本的透明度从0变为1。
代码如下:
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Player2");
{
SceneManager.LoadScene(0);
}
}
答案 0 :(得分:0)
在脚本中放置对Text对象的引用,确保包含Unity UI对象:
using UnityEngine.UI;
public Text textRef;
然后通过检查器将Text对象拖入其中。在对撞机检查中,抓住“文本”对象的颜色并更改Alpha,然后将其重新设置为“文本的颜色”。
Color textColor = textRef.color;
textColor.a = 1.0f;
textRef.color = textColor;
有什么问题吗?