public override void InstantiateThis(EnumResourceType materialType) { if (matDict.ContainsKey(materialType.ToString())) { gameObject.GetComponent <MeshRenderer>().material = matDict[materialType.ToString()]; } }
/// <summary> /// Every Craftable Item is created through this function /// </summary> /// <param name="Item">This is one of many types of Enums (ClothingItems, EquipableItem, TrinketItem, ConsumableItem, ContainerItem)</param> /// <param name="resourceType"></param> /// <param name="itemDictionary"></param> /// <returns></returns> private GameObject CreateCraftableItem(object Item, EnumResourceType resourceType, Dictionary <string, GameObject> itemDictionary) { GameObject item = null; if (itemDictionary.ContainsKey(Item.ToString() + "Prefab")) { print("The prefab was found "); item = GameObject.Instantiate(itemDictionary[Item.ToString() + "Prefab"]); item.GetComponent <BasePrefabInterface>().constructor(Item); print(item.ToString()); //Extract the prefab info to ensure right resourceType. if (item.GetComponent <BasePrefabInterface>().matDict.ContainsKey(resourceType.ToString())) { item.GetComponent <BasePrefabInterface>().InstantiateThis(resourceType); } else { print("Material does not match"); Destroy(item); } } return(item); }