I have a prefab with a script attached to it, I am trying to access a text GameObject to count up, I tried plenty of things. My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class TreeItem : MonoBehaviour
{
public GameObject obj;
public float itema = 0;
void Start()
{
player = GameObject.FindGameObjectWithTag("tree").GetComponent<Transform>();
}
public void Wreck()
{
Debug.Log("clicked");
itema = itema + 1;
Destroy(this.gameObject);
}
void Update()
{
Tree.text = itema.ToString();
}
}