Collected items in GUI

I want to make GUI for displaying collected items.

Here is a code:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class CollectedItems : MonoBehaviour {

	public GameObject item;
	void Items()
	{
		item = GameObject.Find ("Kanister");

		string itmTxt = "Zebrano: "
			+ item;
		
		GUI.Box (new Rect (Screen.width / 2, Screen.height / 2, 200, 200), itmTxt);
	}
}

And also code for collecting items:

using UnityEngine;
using System.Collections;

public class AnotherCollectables : MonoBehaviour {
	
	void OnTriggerEnter2D(Collider2D collider)
	{
		
		switch (collider.gameObject.name) 
		{
			
		case "Player":
			
			Destroy (this.gameObject);
			
			break;
		}
	}
	
}

PS im using my native language in script as “Kanister” or "Zebrano: " they mean GasCan and Collected

you cant display a object (item variable) in ongui function ! u can print their name by :

item.transform.name

you should count them if you wana display how many are they !

u can do it in so many ways ! if u wana more help , tell me :slight_smile: