public void OnDrop(PointerEventData eventData) { ItemHarness harness = m_Inventory.GetFirstSeedItemAtPosition(m_iPosition); if (!harness) { return; } if (m_rObjectPlacer.ObjectRayCastCheck(harness.GetItem().m_3DModel)) { m_Inventory.RemoveFirstSeedItemAtPositon(m_iPosition); Debug.Log("Drop Item"); } }
private void AddInventoryItem(Item _ItemToAdd, ref List <List <ItemHarness> > _ListToAddTo) { // Add item to Harness ItemHarness newItem = gameObject.AddComponent <ItemHarness>(); newItem.SetItem(_ItemToAdd); // See if any current plant in seed inventory has the same name int iPositionToPlaceAt = 0; bool bFoundPositionToAddTo = false; foreach (List <ItemHarness> items in _ListToAddTo) { if (items[0].GetItem().name == newItem.GetItem().name) { bFoundPositionToAddTo = true; break; } ++iPositionToPlaceAt; } if (bFoundPositionToAddTo) { // Add item to that item type _ListToAddTo[iPositionToPlaceAt].Add(newItem); print("Added to existing array"); } else { // Create a new list and add item to that type List <ItemHarness> tempList = new List <ItemHarness>(); tempList.Add(newItem); _ListToAddTo.Add(tempList); print("Added to new array"); } }