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.

Any help would be appreciated.

EDIT:

Here is how i’ve been trying to display the Sprite:

int imageNumber = weaponList [page, 20];
		spriteToUse = imageList [imageNumber];

and here is how i’ve been trying to set it (as non-static):

   public Sprite image0;
   public Sprite image1;
   public Sprite image2;

    	public Sprite[] imageList = new Sprite[] {
                      image0,
                      image1,
                      image2,
                     ...
    };

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.)

I’ve figured it out.

I hope this helps someone else in the future.

To make a Sprite array, you need to do the following:

public Sprite[] spriteList;

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)