Checking for every item in crafting system?

I started coding a crafting system, and it’s working, except for one small problem. It doesn’t check for every material, just one. I tried different ways of fixing it (foreach loop, for loop, if statement in both of those, etc.), and I’m stumped. Anybody know what I’m doing wrong?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CraftButton : MonoBehaviour {

	public CraftingRecipe recipe;
	public Sprite icon;
	public Button craftButton;
	Inventory inventory;

	public bool canCraft;
    
	void Start () 
	{
		inventory = Inventory.instance;
	}
    
	void Update () 
	{
		CheckForMaterials();


		if(canCraft == true)
		{
			craftButton.interactable = true;
		} else
		{
			craftButton.interactable = false;
		}
	}

    public void Craft()
	{
		if(canCraft == true)
		{
			inventory.Add(recipe.result);
			RemoveMaterials();
		}
		else
		{
			Debug.Log("materials not found");
		}
	}

    public void CheckForMaterials()
	{
        
		for (int i = 0; i < inventory.items.Count; i++)
        {
			if (inventory.items _== recipe.Materials*)*_

{
canCraft = true;
Debug.Log(“crafting materials found”);
break;
}
}
* }*

public void RemoveMaterials()
* {*
* for (int i = 0; i < recipe.Materials.Count; i++)*
* {*
_ inventory.Remove(recipe.Materials*);
}
}
}*_

I think the problem lies in this conditional:

if (inventory.items _== recipe.Materials*)*_

What you’re saying here is that there’s a 1:1 relationship between the items in the player inventory and those on the recipe, which is highly unlikely. If the player’s inventory has a different order (which will almost always be the case), this conditional fails consistently. You should use Contains, given that inventory is a List. You’ll loop over the recipe’s items instead of the entire inventory as well, which should be more efficient.
if (inventory.items.Contains(recipe.Materials*))*