// clear all items from a single chest private void ClearChest(Chest chest) { chest.ClearChest(); Undo.RecordObject(chest, "Chest Clear"); EditorUtility.SetDirty(chest); }
/** * 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); }