How do I access the individual frames of a sprite I just auto-sliced?

Pictured below a sprite sheet that I imported into my project. I then went into the sprite editor and auto-sliced it. I added a sprite renderer to the game object and set the Sprite property of it to the newly-sliced sprite.

Now when I run the app the object shows up with the first image of the imported sprite. In script I want to wait a few seconds and change it to a different color ball. I can’t quite figure out how to reference other image frames in the sliced sprite.

Can anyone give me some advice?

Adapted from this answer: Loading a Sprite (Unity 4.3) in resource folder and setting it in sprite renderer - Unity Answers

How about this:

public class AnimationFramePickerSystem : MonoBehaviour {
	
	public string sheetname;
	private Sprite[] sprites;
	private SpriteRenderer sr;
	private string[] names;

	void Start () 
	{
		sprites = Resources.LoadAll(sheetname); 
		sr = GetComponent<SpriteRenderer> ();
		names = new string[sprites.Length];

		for(int i = 0; i < names.Length; i++) 
		{
			names _= sprites*.name;*_

* }*
* }*

* void ChangeSprite( int index )*
* {*
* Sprite sprite = sprites[index]*
* sr.sprite = sprite;*
* }*

* void ChangeSpriteByName( string name )*
* {*
* Sprite sprite = sprites[Array.IndexOf(names, name)];*
* sr.sprite = sprite;*
* }*
}

I’m very new to unity myself so there might be a better way of doing this.

Add a script to your sprite and do something like:

public class AnimationFramePickerSystem : MonoBehaviour {

	public Sprite[] array;
	void Start () {
		GetComponent<SpriteRenderer>().sprite = array[2];
	}

In your project you can now drag the slices from the project asset list into the new fields that become available underneath your script in the component view (it will ask you to set a size first). In my case I just fudged an array item at index 2 above to test, but you could replace that with an actual number.

Adding to tbj22 's answer i had a scenario where i needed to reference single sprites within more than one sprite sheet by their individual names. This was for a custom sprite font. So i did this…

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TextManager : MonoBehaviour {

	private Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>();
	private Sprite[] numberSprites, alphaSprites;

	void Awake () {

		numberSprites = Resources.LoadAll<Sprite>("Graphics/Text/numbers"); 
		alphaSprites = Resources.LoadAll<Sprite>("Graphics/Text/aplhas"); 

		for(int i = 0; i < numberSprites.Length; i++) {
			sprites.Add(numberSprites_.name, numberSprites*);*_

* }*

* for(int i = 0; i < alphaSprites.Length; i++) {*
sprites.Add(alphaSprites_.name, numberSprites*);
}*_

* }*

* public Sprite loadSprite(string name){*
* return sprites[name];*
* }*

}

why can’t you not directly access a slice?