Having trouble with LoadAll

I’ve been following a tutorial to figure out how to make a puzzle game: Unity Memory Game Tutorial - 5 - Getting Sprites - Memory Game In Unity - YouTube

My problem is in the first three minutes and it involves the LoadAll bit of his script. You see, unlike the guy in the tutorial, I’m using a folder for Candy whereas he’s using… something. I actually can’t quite tell what he’s using by the icon that is shown (I’m still a bit new to Unity I guess :P). The exact icon for what Candy is is found at 1:00.

Anyway, due to my using a folder instead of… whatever he’s using, I’m getting an error. To say what exactly is going on, I’ll show you my script:

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

public class GameController : MonoBehaviour {

	public Sprite bgImage;

	public List<Button> btns = new List<Button> ();

	public Sprite[] puzzles;

	public List<Sprite> gamePuzzles = new List<Sprite>();

	private bool firstGuess, secondGuess = true;

	private int countGuesses;
	private int countCorrectGuesses;
	private int gameGuesses;

	private int firstGuessIndex, secondGuessIndex;

	private string firstGuessPuzzle, secondGuessPuzzle;

	void Awake (){
		puzzles = Resources.LoadAll<Sprite> ("Sprites/Candy");
	}



	// Use this for initialization
	void Start () {
		GetButtons ();
		AddListeners ();
		AddGamePuzzles ();
		gameGuesses = gamePuzzles.Count / 2;
		Shuffle (gamePuzzles);
	}
	
	// Update is called once per frame
	void GetButtons () {
		GameObject[] objects = GameObject.FindGameObjectsWithTag ("PuzzleButton");
			for (int i = 0; i < objects.Length; i++) {
			btns.Add(objects *.GetComponent<Button> ());*

_ btns .image.sprite = bgImage;;_
* }*
* }*

* void AddGamePuzzles (){*
* int looper = btns.Count;*
* int index = 0;*

* for(int i = 0; i < looper; i++){*
* if (index == looper / 2) {*
* index = 0;*
* }*

* gamePuzzles.Add (puzzles [index]);*

Don’t mind the parsing errors. I just want to show what is necessary. Anyway, I’m getting an error regarding the last line of code. It says the following: “Array index is out of range.”
I know that this error is regarding the Resources.LoadAll bit, because that is the ONLY time in the entire tutorial that I had a slightly different situation before me, and that situation is that I have a folder for “Candy” rather than… whatever that guy has. Is there some way to fix this, or am I utterly doomed D:

The namespace functions like Load and LoadAll require that the resources in question be under a folder named Resources. His project folder is not set up correctly. For his code and your code to work properly you need to create a Resources folder and place your Sprites folder inside it. Like this

70313-inspector.png

Also, inside “AddGamePuzzles” index is alway 0. So your code will always be doing this

gamePuzzles.Add (puzzles [0]);

In Start() you may want to do this

GetButtons ();
if ((puzzles != null) && (puzzles.Length > 0) && (btns.Count > 0))
{
    AddListeners ();
    AddGamePuzzles ();
}