Почему то ошибку выдает:
InvalidCastException: Specified cast is not valid.
Inventory.RenderItems () (at Assets/Scripts/Inventory.cs:17)
Inventory.OnEnable () (at Assets/Scripts/Inventory.cs:12)
Код:
public class Inventory : MonoBehaviour
{
[SerializeField] private List<Item> Items;
[SerializeField] private Transform _contaner;
[SerializeField] private InventoryCell _inventotyCell;
private void OnEnable()
{
RenderItems();
}
private void RenderItems()
{
foreach(GameObject child in _contaner)
{
Destroy(child);
}
Items.ForEach(item =>
{
var cell = Instantiate(_inventotyCell, _contaner);
cell.Render(item);
});
}
}