Hi, i’m making a inventory with tooltip, and i want to access a two string variables from another script (that script is in every object, so every object has their description), and put them into a two diferents Text, to show at the screen. but i don’t get to make it right…
i try to call the other script in different ways, like “InteracObject.GetComponent();” but i guess i’m not makeing it right
if someone could help…
(i’m just going to put the part of the code that about this)
the first one is the script that is attach to every item:
public class InteracObject : MonoBehaviour {
public string itemTitulo; //title of the item
public string itemDescriçao; //description of the item
}
the second one is attach to the player, and is the Inventory script:
public class Inventory : MonoBehaviour
{
public GameObject toolTip;
public Text visualText;
public void ShowToolTip (GameObject item)
{
toolTip.gameObject.SetActive (true); //active the canvas of tooltip
}
public void HideToolTip ()
{
toolTip.gameObject.SetActive (false); //active to false, the canvas of tooltip
}
}