Question by
beekobeeko · May 27, 2017 at 08:34 PM ·
gui2d gameitem pickup
how to add picked up items in gui?
hey folks..., i've got this nice script for picking up and storing items. the problem is that i don't have any clue how to make em appear in a gui inventory. hope anyone can help me out. complete noob with unity here. sorry for bothering!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerInventory1 : MonoBehaviour
{
public GameObject[] inventory = new GameObject [2];
public void AddItem(GameObject item)
{
bool itemAdded = false;
for(int i=0; i < inventory.Length; i++)
{
if (inventory[i] == null)
{
inventory[i] = item;
Debug.Log(item.name + " was added");
itemAdded = true;
item.SendMessage("DoInteraction");
break;
}
}
if (!itemAdded)
{
Debug.Log("Inventory Full - Item Not Added");
}
}
}
Comment
Answer by ismaelnascimento01 · May 27, 2017 at 08:41 PM
Check link: https://www.youtube.com/watch?v=ZW6RCKVnqT4 - Use Unity UI
Check my comment as the answer to the question. I thank you
Your answer
Follow this Question
Related Questions
Problem with Strings updatings on Gui 0 Answers
Music playing from 2 different scenes - how to fix? 1 Answer
UI Text Editing Problem, What's Wrong? Need Anybody to Assist 1 Answer
Make a game introduction 1 Answer
Chagning layers by button 0 Answers