An object reference is required to access non-static member

Ok, I understand this error, and I know the answer is simple: “Declare a static variable”.
But my problem is: I want to use a simple public variable, so that I can drag and drop the GameObjects onto them in the inspector, which is impossible using a static variable.

The error says: “An object reference is required to access non-static member”, what is this “object reference”? And how can I use it?

Here is the simplified version of the code:

public class InventorySystem : MonoBehaviour
{
        public static GameObject[] inventory;
        public GameObject[] inventorySlot;
        public Material item_Key, item_Cube, item_Sphere;

        void Start ()
	    {
		inventory = new GameObject[slots];
        }

        void Update()
        {
                ...
        }

        public static void SortMenu()
	    {
		for(int i = 0; i < slots; i++)
		{
			switch(inventory*.name)*
  •  	{*
    
  •  		case "Cube1":*
    

inventorySlot*.renderer.material = item_Cube;
_
break;_
_
case “Cube2”:_
inventorySlot.renderer.material = item_Cube;
_ break;
case “Sphere”:_
inventorySlot.renderer.material = item_Sphere;
_ break;
case “Sphere2”:_

inventorySlot.renderer.material = item_Sphere;
_ break;
}
}
}
}_

_And the exact error I’m getting is: “An object reference is required to access non-static member `InventorySystem.inventorySlot’”, inside the switch estatement on the lines containing "inventorySlot.renderer.material".*
I know I can use Find, but I really want to avoid using it, although, if there’s no option I’d have no other choice, but I want to understand more this error.
Thank you._

You cannot access nonstatic fields of class inside static method. So they both should be static or nonstatic.

One way to solve it - remove static keyword from method definition and somehow remember or get an instance of InventorySystem object.
I guess InventorySystem object could be a singleton.