Hello guys, I am making a very simple thing but I just couldnt get it work.
So what I wanna do is. 3 buttons . A, B and C on GUI. Using TextMeshProUGUI.
example.
When clicked A, the text in button A’ will change.
It’s like checking for an item’s information.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ItemInfo : MonoBehaviour
{
// Start is called before the first frame update
TextMeshProUGUI text;
public GameObject[] iteminfo; // Button array
int i;
void Start()
{
text = gameObject.GetComponentInChildren<TextMeshProUGUI>();
}
// Update is called once per frame
void Update()
{
}
public void showInfo()
{
text.text = iteminfo[i].name; // show item info.
}
}
Much thanks!