Creating a new GameObject by code without an inspector prefab

So In this game the player can find chests, these chests can have, at ramdom, one of ten different items.

So when the player opens a chest this happens:

// Mockup code
[SerializeField] GameObject[] items;

void OpenChest() 
{
  int index = Random.Range(0, items.Lenght);

  Instantiate(items[index]);
}

The problem with this solution is that I need to drag the 10 items (gameobjects) to the chest’s script, and that’s for every chest in the game. It seems like a waste of resources. Is there a way to Instantiate or create an gameobject on the fly, without having an instance in the inspector. For example:

int index = Random.Range(0, items.Lenght);

switch(index)
{
 case 0: Create(BlueCoin); break;
 case 1: Create(Sword); break;
...
}

You can use Resource.Load() to get a prefab by name. You could also use something like a scriptable object that holds all the prefabs and links them to, for example, an index.

Thanks a lot, that was very useful.