Hey Folks!
i use two scripts. my enum part looks like this:
public enum ItemType {
**Sword,
Armor,
HealthPotion,
Dagger,**
}
Now I want to add a new item in my other script. My Problem is that i want to transfer a string instead of Sword, Armor, HealthPotion or Dagger with the same value in it.
For example: My other script has a
string variable with the value
“Dagger”
GameObject.FindWithTag("gun").name = weaponname;
How can I use the string “weaponname” in the following code? instead of the enum.
inventory.AddItem(new Item { itemType = Item.ItemType.(here i want to use a string instead of Sword, Armor, HealthPotion or Dagger), amount = 1 });
Do you know if this is possible? I would be really happy if you can help me!
Please let me know if you dont understand my problem. it’s little bit hard for me to discribe it.