void SaveConsumable() { if (itemModel == null) { return; } if (string.IsNullOrEmpty(itemId)) { return; } ConsumableScriptableObject obj = Resources.Load("ConsumableScriptableObject") as ConsumableScriptableObject; if (obj == null) { return; } for (int i = 0; i < obj.consumables.Count; i++) { if (obj.consumables[i].item_id == itemId) { Consumable c = obj.consumables[i]; c.r_model_eulers = itemModel.transform.localEulerAngles; c.r_model_pos = itemModel.transform.localPosition; c.model_scale = itemModel.transform.localScale; return; } } Debug.Log(itemId + " wasn't found in inventory."); }
//Consumables public Consumable GetConsumable(string id) { ConsumableScriptableObject obj = Resources.Load("ConsumableScriptableObject") as ConsumableScriptableObject; if (obj == null) { Debug.Log("ConsumableScriptableObject could not be loaded"); return(null); } int index = GetIndexFromString(consumableIds, id); if (index == -1) { return(null); } return(obj.consumables[index]); }
void LoadConsumableIds() { ConsumableScriptableObject obj = Resources.Load("ConsumableScriptableObject") as ConsumableScriptableObject; if (obj == null) { Debug.Log("ConsumableScriptableObject could not be loaded"); return; } for (int i = 0; i < obj.consumables.Count; i++) { if (consumableIds.ContainsKey(obj.consumables[i].item_id)) { Debug.Log(obj.consumables[i].item_id + " item is a duplicate"); } else { consumableIds.Add(obj.consumables[i].item_id, i); } } }