So i have the class “Item” for all the items in the game that the player will be able to interact with. I then have an array EquipMenu with items the player currently has equipped.
public class Item
{
var Item_ID : int;
var Name : String;
var Description : String;
var icon : Texture2D;
var Health : float;
var Energy : float;
var Damage : float;
var rarity : Rarity;
var itemType : ItemType;
}
At the moment when i need to Instantiate an “Item” i get the Item ID as follows:
var item_id : int = EquipMenu[equip_selection].Item_ID;
I then use the Item ID to select the prefab from an array of GameObjects to then instantiate.
I would much rather define the prefab in the class as follows:
public class Item
{
var prefab : GameObject;
}
But this requires the class to extend MonoBehaviour, i believe, in order to hold the prefab.
This then means that i cannot define the items in the Inspector as before, as the drop down disappears.
Do i have to define the Items within the script (thus, not saving me any time at all, i may as well stick with my current method) or is there any way around this??
Many Thanks