private void ReSync() { var newList = new List<InventoryPlayerEquipTypeBinder>(); var equipSlotFields = tar.characterCollection.container.GetComponentsInChildren<InventoryEquippableField>(true); for (int i = 0; i < equipSlotFields.Length; i++) { InventoryPlayerEquipTypeBinder toAdd = new InventoryPlayerEquipTypeBinder(equipSlotFields[i], null, InventoryPlayerEquipHelper.EquipHandlerType.MakeChild); // Find in old data var found = tar.equipLocations.FirstOrDefault(o => o.associatedField == equipSlotFields[i]); if (found != null) { toAdd = found; //toAdd = new InventoryPlayerEquipTypeBinder(t.equipLocations[i].associatedField, t.equipLocations[i].equipTransform); } newList.Add(toAdd); } tar.equipLocations = newList.ToArray(); GUI.changed = true; // To save list.list = tar.equipLocations; // Update list Repaint(); }
/// <summary> /// Called when the item is equipped visually / bound to a mesh. /// Useful if you wish to remove a custom component whenever the item is equipped. /// </summary> /// <param name="binder"></param> public void NotifyItemUnEquippedVisually(InventoryPlayerEquipTypeBinder binder, InventoryPlayer player) { if (OnUnEquippedVisually != null) OnUnEquippedVisually(binder, player); }