Hello! Im trying to set text from Pickup script assigning variable and updating text in script on UI, but its working only on one object, on others text isn't showing.
Maybe someone can see the problem?
**Pickup script**:
public enum Items
{
Garbage,
Dishes,
Water,
Milk
}
void Update()
{
float dist = Vector3.Distance(playerTransform.position, transform.position);
if (dist <= radius)
{
string txt = item.ToString();
displayTxt = "Press E to Collect " + txt ;
if (Input.GetKeyDown(KeyCode.E))
displayTxt = "";
}
else displayTxt = "" ;
}
**Tooltip script:**
public static Text textObject;
public static string textValue = "";
void Start()
{
textObject = GetComponent();
}
void Update()
{
textValue = PickupItem.displayTxt;
textObject.text = textValue;
}
↧