如何在 ac# 脚本中制作和更改文本?
我目前有这段代码,但它不起作用,因为我告诉脚本我要更改的文本是什么:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class treeBreak : MonoBehaviour
{
public float woodCount = 0;
public Text woodText;
private void OnTriggerEnter2D(Collider2D other){
if (other.CompareTag("sword")){
Destroy(gameObject);
woodCount = woodCount + 1;
}
}
void Update(){
woodText.text = woodCount.ToString();
}
}