Argument Out of Range when accessing List

In Script One I create a “Big List” of 15 items, each item contains three Integers – at present, it’s merely meaningless test data.

In Script Two, I print the entire list, 15 items, three integers each – no problem, the list picks up the data and prints it perfectly…random numbers or assigned numbers, I have no problem at all extracting the full list and printing it accurately.

In Script Three I create a “Small List” of three items selected from the “Big List” in Script One and I get the message “ArgumentOutOfRangeException: Argument is out of range. Parameter name: index”

Here is script one:

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

public class ScriptOne : MonoBehaviour
{
	public List<NumTestClass> bigList = new List<NumTestClass> ();

	void Start() 
	{
		for (int i = 0; i < 15; i++) 
		{
			int num01 = 11;
			int num02 = 22;
			int num03 = 33;

			bigList.Add (new NumTestClass (num01, num02, num03));
		}
	}
}

public class NumTestClass
{
	public int numberOne {get; set;}
	public int numberTwo {get; set;}
	public int numberThree {get; set;}

	public NumTestClass (int one, int two, int three)
	{
		numberOne = one;
		numberTwo = two;
		numberThree = three;
	}
}

Here is script two: ///////////////////////////////////////////////////////////////////

using UnityEngine;
using System.Collections;

public class ScriptTwo : MonoBehaviour
{
	void OnGUI()
	{
		for (int i = 0; i < 15; i++) 
		{
			string tempString01 = GetComponent<ScriptOne> ().bigList *.numberOne.ToString("F1");;*

_ string tempString02 = GetComponent ().bigList .numberTwo.ToString(“F1”);_
_ string tempString03 = GetComponent ().bigList .numberThree.ToString(“F1”);_

_ GUI.Label (new Rect (25, i * 25 + 100, 150, 20), tempString01 + " - " + tempString02 + " - " + tempString03);
* }
}
}*_

Here is script three //////////////////////////////////////////////////////////////////////
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ScriptThree : ScriptOne
{
* public List smallList = new List ();*

* void Start ()*
* {*
* int counter = 0;*

* while (counter < 3)*
* {*
* int temp01 = GetComponent().bigList[counter].numberOne;*
* int temp02 = GetComponent().bigList[counter].numberTwo;*
* int temp03 = GetComponent().bigList[counter].numberThree;*

* smallList.Add(new RaceTestClass (temp01, temp02, temp03));*
* counter++;*
* }*
* }*
}

public class RaceTestClass
{
* public int thingOne { get; set;}*
* public int thingTwo {get; set;}*
* public int thingThree {get; set;}*

* public RaceTestClass (int one, int two, int three)*
* {*
* thingOne = one;*
* thingTwo = two;*
* thingThree = three;*
* }*
}

This looks a lot like a Script Execution Order issue.

Script3 is accessing members of Script1 upon Start (), while Script1 may execute after Script3.

Best option is to initialise your data in Script1 in Awake().
All Awake calls are called before any Start call.

Otherwise you can also go into Script Execution Order, and force the order so that Script3 gets called after Script1.

The Start() methods of both scripts are executed in an arbitrary order. Hence if the Start() method of scrpt 3 gets called first you are trying to access the List from Script 1, which is empty at this point. Hence you get the Argument Out of Range Error.
To solve that you can either set the Script excution order manually:Unity - Manual: Script Execution Order settings or (what I would prefer) implement are logic where the Lists get filled in te right order.