Atlases and sprites

It is a stupid question, but I can’t get any help from the doc of the v4.3.

I have an atlas with 128x8 sprites.
I can slice them with the new sprite import features.

Now I just want to display them (1,2,3,4,5 and loop).

I just can’t find how to tell the sprite renderer which index in the atlas it has to display.

Anyone got this problem and solved it? (I use JS)

Note
spriteRenderer.sprite=spritelist[currentsprite];
is not working while

lineRenderer would support this syntax.

Ok I found the solution:

gameObject.GetComponent(SpriteRenderer).sprite=spritelist[currentsprite];

I’ve been trying to do this for a long time with no luck, could you elaborate more on this … maybe post the exact code of how you created the object and assigned a particular slice to it.

Thanks in advance