首先,创建一个text的ui组件,在其中写上你需要的文字。
接着对大小颜色等等进行调整:

制作好之后,接着禁用该组件:

接着完成就是通过条件代码激活该UI组件。
在玩家的代码中编写脚本如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class player_move : MonoBehaviour
{
public int score = 0;
public Text ScoreText;
public GameObject winText;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Rigidbody rd = GetComponent<Rigidbody>();
rd.AddForce(new Vector3(h, 0, v) * 13);
}

这篇博客介绍了如何在Unity的RollABall教程案例中创建游戏胜利的UI提示。首先,通过UI系统创建并配置一个Text组件,设置文字内容和样式。然后,初始状态下禁用该组件。最后,编写玩家脚本,当达到胜利条件时,通过代码激活UI组件显示胜利信息。
最低0.47元/天 解锁文章
3714

被折叠的 条评论
为什么被折叠?



