IndexOutOfRangeException: Index was outside the bounds of the array. UIScript.UpdateE () (at Assets/

Hey, thats my error:

IndexOutOfRangeException: Index was outside the bounds of the array.
UIScript.UpdateE () (at Assets/Scripts/UIScript.cs:15)
ScoreScript.Start () (at Assets/Scripts/ScoreScript.cs:17)

I cant find my mistake…

Here is my code:

Cloud Variables:

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

public class CloudVariables : MonoBehaviour
{
public static int[ ] ImportantValues { get; set; }

private void Awake()
{
ImportantValues = new int[3];
}
}

UIScript:

using UnityEngine;
using UnityEngine.UI;

public class UIScript : MonoBehaviour
{
public Text[ ] ValueTextArray;

public void UpdateH()
{
ValueTextArray[0].text = "Highscore: " + CloudVariables.ImportantValues[0];
}

public void UpdateE()
{
ValueTextArray[1].text = “” + CloudVariables.ImportantValues[1];
}

public void UpdateG()
{
ValueTextArray[2].text = “” + CloudVariables.ImportantValues[2];
}

public void Save()
{
PlayGamesScript.Instance.SaveData();
}

public void Increment(int index, int erhöhen)
{
CloudVariables.ImportantValues[index] = CloudVariables.ImportantValues[index] + erhöhen;
ValueTextArray[index].text = CloudVariables.ImportantValues[index].ToString();
}

public void Replace(int index, int wert)
{
CloudVariables.ImportantValues[index] = wert;
ValueTextArray[index].text = CloudVariables.ImportantValues[index].ToString();
}
}

I hope you can help me to find my misstake…

Here are some notes on IndexOutOfRangeException and ArgumentOutOfRangeException:

http://plbm.com/?p=236

I know that… But the length of my array is 3 and I use 0,1,2… I think that’s not the problem…

Sry for my english

Did you put a Debug.Log() line in immediately before the error line as the post suggested?

Specifically,

Ok I try it

I found the problem, the length of my array is 1, but I dont know why…

That technique works 100% of the time.

Now you can continue working.

Find out why it is size 1.

Is this script on multiple game objects? Look in the scene. Perhaps only one instance has the right size.

Keep inserting Debug.Log() statements, print out the .name of the GameObject, etc.

It will always work to solve problems this way. Keep digging, it’s there, it’s not magic.