/** * Spawns a chest at the given location in the (x, z) plane */ protected void SpawnChest(List <Item> items, float x, float z) { if (chest == null) { chest = Resources.Load <Chest>("Chest"); } Chest temp = (Chest)(GameObject.Instantiate(chest, new Vector3(x, 0.5f, z), Quaternion.identity)); foreach (Item item in items) { temp.AddToChest(item); } }
public bool AddToChest(GameObject item) { bool x = currentChest.AddToChest(item); if (x) { UpdateChestUI(); } else { return(false); } return(true); }
/** * Add a list of items to one chest */ private void AddToChest(Chest chest, bool clearOnAdd, List <InventoryItem> items) { if (clearOnAdd) { chest.ClearChest(); } foreach (InventoryItem item in items) { chest.AddToChest(item); } // tell the editor that the object has been changed // this prevents changes from disappearing when going into play mode // I believe there is a more current way to do this, but I haven't figured it out yet Undo.RecordObject(chest, "Chest Modify"); EditorUtility.SetDirty(chest); }