NullReferenceException: Object reference not set to an instance of an object

Hi.

I’m trying to create a list of buttons displayed on screen based on some text files I have.

However when I try this I get a NullReferenceException error and I do not know why.

public class QuestionPackSelection : MonoBehaviour 
{
public static TextAsset[] texts = new TextAsset[4];
	GUIStyle PackGui;
	// Use this for initialization
	void Start () {
		TextAsset[] texts = Resources.LoadAll<TextAsset>("QuestionPacks");

	}
	
	// Update is called once per frame
	void Update()
{
		for (int i = 0; i < texts.Length; i++) {
			//Debug.Log (texts*.name);*

GUI.Button(new Rect(Screen.width - 200, 80+(55i), 120, 50),texts.name,PackGui);*
}
}
Using a Debug to show the title of the text files works jsut fine, but upon displaying it; the code breaks.

public static TextAsset texts = new TextAsset[4];

Hi, i dont think you can do that, it can/should be in Start instead.

public static TextAsset[] texts;

function Start(){
    texts = new TextAsset[4];
}

And by the way, i dont think you need them static for this kind of purpose.