Hi
I have the problem when drag the items to other inventory i want to save in one List the objects but i can’t because not Add nathing to list.
This my function when have a problem:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class Inventory : MonoBehaviour, IHasChangedPlace {
[SerializeField] Transform slots;
public List<GameObject> itemsList;
// Use this for initialization
void Start () {
itemsList = new List<GameObject>();
HasChangedPlace ();
// Inicializa a lista de Objectos
}
public void HasChangedPlace(){
foreach (Transform slotTransform in slots) {
GameObject item = slotTransform.GetComponent<Slot> ().item;
if (item) {
//GameObject moveDown = slotTransform.GetComponent<Slot> ().item;
Debug.Log (item.name);
itemsList.Add (item);
}
}
}
}
namespace UnityEngine.EventSystems{
public interface IHasChangedPlace: IEventSystemHandler{
void HasChangedPlace ();
}
}