using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Well : MonoBehaviour
{
public int currentLiter = 5;
public int maxWellCapacity = 10;
public float refillTime = 8f;
public Text wellDurText;
public Image refillTimeText;
public GameObject player;
public void Update()
{
if (currentLiter < maxWellCapacity)
{
RefillWell();
}
wellDurText.GetComponent<Text>().text = currentLiter.ToString();
wellDurText.transform.LookAt(player.transform);
refillTimeText.GetComponent<Image>().fillAmount = refillTime/8;
refillTimeText.transform.LookAt(player.transform);
}
void RefillWell()
{
refillTime -= Time.deltaTime;
if (refillTime <= 0.0f)
{
currentLiter += 1;
refillTime = 8f;
}
}
}
我想要做的事情是:让wellDurText无论玩家在哪里都面向玩家,但由于某种原因,它被翻转了。 我尝试过手动从编辑器翻转UI,但当我在游戏中尝试时,它又翻转回来了。