Why does indexing of sprite-multiple object members begin with 1 instead of 0?

I have this sprite sheet split in 20 cells in the Sprite Editor.
If I do

stripIcons = Resources.LoadAll(“spriteStrip”);
iconSprite = stripIcons[0];
print(iconSprite);

I get the “InvalidCastException: Cannot cast from source type to destination type.” error.

If I do instead

stripIcons = Resources.LoadAll(“spriteStrip”);
iconSprite = stripIcons[1];
print(iconSprite);

It prints out :

spriteStrip_0 (UnityEngine.Sprite)

and all is fine.

I can access all the members of the sprite sheet, from 1 to 20 instead of the 0-19 I would have expected.
What is it I don’t get about sprite-multiple objects indexing?

function Start () {
    var stripIcons = Resources.LoadAll("SpriteStrip");
    var iconTexture = stripIcons[0];
    print(typeof(iconTexture));
    var iconSprite = stripIcons[1];
    print(typeof(iconSprite));
}

–Eric

Thanx.
So the first element in that object is a texture and the rest are sprites?!
Can you point me where in the doc I can have a look at this strange object?
I can’t figure at what point what becomes an array…

Yes, the first entry is the texture, the rest are sprites. You can’t have sprites without a texture. It’s not defined anywhere that the first entry is always the texture, though, so it might be best not to take that for granted.

–Eric

In order to disambiguate this, load the resources with a type:

stripIcons = Resources.LoadAll<Sprite>("spriteStrip");

iconSprite = stripIcons[0];