Question by
strandgear · Sep 13, 2021 at 03:45 PM ·
scripting problem2d gametextinterfacetips
Tooltip doesn't work
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<Text>();
}
void Update()
{
textValue = PickupItem.displayTxt;
textObject.text = textValue;
}
Comment
Your answer
Follow this Question
Related Questions
My gameobject stops moving after entering the trigger?? 0 Answers
Jump Script 2 Answers
How do I display AudioMixer volume as a percentage 2 Answers