C# - How to set the sprites in a Static Sprite[] array

I have an image GameObject that changes Sprite depending on the inventory page. So when a user clicks an item, it changes the image to match that. I'm trying to store all of the possible sprites into a Sprite[]. it makes it much easier for coding reasons. However, I'm having a lot of trouble.

I originally started with a public Sprite[], and tried to set it up with public Sprite variables. But for some reason it was always returning null unless i set it up as static. My Sprite[] is now static, as well as the Sprite variables i want to put into the array. However, i can't click and drag the sprites into their public variables anymore, through the inspector, because they are now static, and I don't know how to set sprites any other way.

Now I'm somewhat stuck. I even tried (shamefully) to make a bunch of public Sprites, and then tried to set the static Sprites by the non-static ones, - like public static image0 = otherImage; but apparently non-static sprites won't be accepted into a static sprite variable.

I've tried the Resources.LoadAll method, but it's confusing, and i can't figure out how to SEE let alone set the images up in the right order into my Sprite[].

If I create a static Sprite[] and static Sprites to fill it, it will recognise it, and not get a null exception when i try to get it. However, I don't know how to properly set static Sprites into a Sprite array. (I normally just use the inspector to drop and drag sprites onto their public variable placeholders.)

hang on, I'm also getting told that my field initialiser cannot reference a non-static method or property. (That may explain the out of range error). so my Sprite[] = new Sprite[] {image0, ...}; all get errors, because none of them are static.
EDIT: nope, i fixed this by moving it into void Start() {} and I'm still getting out of range error.

Then through the inspector, set the size of the array, and drag and drop your sprites onto the empty elements within the inspector.

You do not need to create other variables to hold sprites, they will all be held in the Sprite array.

trying to set or change a Sprite array during runtime doesn't seem to work, everything gets ignored (I'm assuming this is a unity thing) you have to do it in the inspector. You cannot set the size of the array in your script, it has to be done in the inspector. (that too, gets ignored)

(Seriously, I'm shocked this hasn't been explained in the API - Documentation, it is not intuitive to know this)

Setting or changing an array at runtime works just fine. What you're getting thrown by, I suspect, is how variables are serialised and initialised, which is somewhat esoteric.

A private variable (array or otherwise), by default, is not serialised. That means you can declare it and use it in code as normal, but it won't appear in the inspector.
A public variable is serialised. Crucially, any values assigned to a public variable in the inspector will override the initalisation declared in code. So if you have a variable declared in a component as follows:

public int number = 2;

but in the inspector for that component assign a value of 5, say:

Then number will have a value of 5, not 2. From your description, it sounds like you declared a public sprite array in code, but did not assign any sprites in the inspector. Thus, your sprite array was being initialised as an empty array, which is why you got null reference errors.

Note that, unless, the values in that array need to be accessed by a method in another class, you shouldn't be declaring it as public anyway. If you simply set spriteList as private then you can initialise it in code as you were expecting. Alternatively, set it as public but use the inspector for initialisation.

yes, however i never even touched the inspector. So even after attempting to set size, and all the elements by code, the inspector (which i never engaged with) was overriding it. However, if i were to normally leave a public int variable, and not touch it via the inspector, it would still let the script determine its value, and the inspector would normally inherit those values, but the Sprite array, decides to behave slightly differently.