Object Reference not set to an instance of an object

I saw that My game is not working properly. So I build it in Development Build with Script Debugger and look what I have found )) .

[29491-безымянный.png|29491]

Here are my scripts

public class MenuScript : MonoBehaviour {

	public int newLevel  ;
	public int numbersOfLevels;
	public bool LevelGo = false;
	public bool StartGame = false;
	public GameObject myObject;
	XMLParserScript menuSriptObj ;

	public GameObject myObjet;
	AutoPositionItems autoObject;

	public GameObject gemObject;
	Board boardObject;
	void Start()
	{
		menuSriptObj = myObject.GetComponent<XMLParserScript> ();
		autoObject = myObjet.GetComponent<AutoPositionItems> ();
		boardObject = gemObject.GetComponent<Board> ();
	}
	void OnGUI()
	{
		if(GUI.Button(new Rect(20,20,120,120), "New Level"))
		{	
			if(!LevelGo)
					boardObject.CreateGemsGrid();

			if(LevelGo){
			//boardObject.DeleteGemsGrid();
			//boardObject.CreateGemsGrid();
				
			}
			LevelGo = true;

//HERE IS THE LINE 37
//HERE IS THE LINE 37
//HERE IS THE LINE 37 Down bellow

			menuSriptObj.LevelList();
			autoObject.DeleteItems();
			autoObject.CreateItems();

			// % will make sure to go from beginning when newlevel == numbersOfLevels - 1
			newLevel = (newLevel+1) % numbersOfLevels;
		}
	}
}

And the second one.

using UnityEngine;
using System.Collections;
using System.Xml;
using System.IO;
using System.Xml.Serialization;
using System.Collections.Generic;

public class XMLParserScript : MonoBehaviour {

	string path = "Assets/Resources/Xml/Level1.xml";

	public MenuScript objectScript;
	public GameObject myObject;
	LevelsDirectory XmlData;
	public bool NewLevel = false;

	//[HideInInspector]
	public int ItemsNumber;
	public string ItemsColor;
	void Start()
	{
		objectScript = myObject.GetComponent <MenuScript>();
		XmlSerializer deserializer = new XmlSerializer (typeof(LevelsDirectory));
		TextReader reader = new StreamReader (path);
		
		// deserializer.Deseralize function is used to deserializethe XML data which is there in XML file
		object obj = deserializer.Deserialize(reader);
		XmlData = (LevelsDirectory)obj;
		reader.Close ();
		LevelList ();
	//	ItemsNumber = XmlData.levelList[0].ItemsNumber;
	}


	public void LevelList()
	{
		switch(objectScript.newLevel)
			{
			case 0:

//HERE IS THE LINE 40
//HERE IS THE LINE 40
//HERE IS THE LINE 40 DownBellow

			ItemsNumber = XmlData.levelList[0].ItemsNumber;
			ItemsColor = XmlData.levelList[0].ItemsColor.ToUpper();
			break;

			case 1:
			ItemsNumber = XmlData.levelList[1].ItemsNumber;
			ItemsColor = XmlData.levelList[1].ItemsColor.ToUpper();
			break;
				
			case 2:
			ItemsNumber = XmlData.levelList[2].ItemsNumber;
			ItemsColor = XmlData.levelList[2].ItemsColor.ToUpper();
			break;

		default:
				break;
				
			}
	}
}
	public class LevelsDirectory
	{
		[XmlElement("Level")]
		public List<Level> levelList = new List<Level> ();
	}

	public class Level
	{
		public int LevelNumber{ get; set; }
		public int ItemsNumber{ get; set; }
		public string ItemsColor { get; set; }
	}

I need some help from you because I don’t really find where is this instance of an object ))

What caleb said and also your object is not pointed to anything, unless you dragged it on the inspector.

In the script shown, levelList is not populated.

public List<Level> levelList = new List<Level>():

is giving you an empty list so trying to access an index without a value could give you null.

If you do think that you are populating the list somewhere, I would start by checking if it is actually getting values.

You could do a simple

Debug.Log(levelList.Count)

to see how many (if any) values it contains.

Resources - Read it carefully

The problem was that the way I accessed the Xml file was wrong.

At build stage, only the assets that are in the Resources file will be compiled.
That’s why I had to Load the Xml File as

TextAsset itemTextFile = Resources.Load ("Xml/Level1") as TextAsset;

and than to parse the itemTexFile.txt