Inventory Tooltip

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 :confused:
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
	}
}

To access those variables in the InteracObject script, you first need a reference it the object the script is attached to. How are you storing your inventory?

Once you have a reference to that object, you can access the script like this…

InteracObject interacObject = ObjectReference.GetComponent<InteracObject >();

In the example above, ObjectReference would be the reference to the object with the InteracObject script attached. This would create a local variable called interacObject that is the InteracObject attached to the reference object.

Then to access one of the variables, you would use interacObject.variablename

Hope this helps,
-Larry