void Update() { if (!saveWeapon) { return; } saveWeapon = false; if (weaponModel == null) { return; } if (string.IsNullOrEmpty(weaponId)) { return; } WeaponScriptableObject obj = Resources.Load("GameControll.WeaponScriptableObject") as WeaponScriptableObject; if (obj == null) { return; } for (int i = 0; i < obj.wepons_all.Count; i++) { if (obj.wepons_all[i].itemName == weaponId) { Weapon w = obj.wepons_all[i]; if (leftHand) { w.l_model_equiped_eulers = weaponModel.transform.localEulerAngles; w.l_model_equiped_pos = weaponModel.transform.localPosition; } else { w.r_model_equiped_eulers = weaponModel.transform.localEulerAngles; w.r_model_equiped_pos = weaponModel.transform.localPosition; } w.model_scale = weaponModel.transform.localScale; return; } } Debug.Log(weaponId + " wasnt found in inventory"); }
public Weapon GetWeapon(string id) { WeaponScriptableObject obj = Resources.Load("GameControll.WeaponScriptableObject") as WeaponScriptableObject; if (obj == null) { Debug.Log("WeaponScriptableObject cant load!"); return(null); } int index = GetWeaponIdFromString(id); if (index == -1) { return(null); } return(obj.wepons_all[index]); }
void LoadWeaponIds() { WeaponScriptableObject obj = Resources.Load("GameControll.WeaponScriptableObject") as WeaponScriptableObject; if (obj == null) { Debug.Log("WeaponScriptableObject coundlt load"); return; } for (int i = 0; i < obj.wepons_all.Count; i++) { if (item_ids.ContainsKey(obj.wepons_all[i].itemName)) { Debug.Log("Item is duplicate"); } else { item_ids.Add(obj.wepons_all[i].itemName, i); } } }