Setting Prototypes from For-Loop?

I have been writing a script to create procedural terrain, I am creating the splats from two Arrays which are:

  • SplatPrototypes SPSS;
  • TerrainTextures TrTx;

TerrainTextures is derived from “TerrainTextures.cs” and contains:

  • Texture2D Tex2D;
  • Texture2D Nml2D;
  • Vector2 TxtSprd;

I’m getting an error that states “TrTx” is empty, which, as the inspector shows, is incorrect.

Heres a Snippet of code:

	public TerrainTextures[] TrTx;
	public SplatPrototype[] SPSS;

	public TerrainController TCB;

	public int Splats = 0;

	public void Start(){
		TCB = GameObject.FindGameObjectWithTag("TCB").GetComponent<TerrainController>();

		VarSetter();
		BiomeSwitch();
		if(!Mathf.IsPowerOfTwo(AfMapSz)){
			AfMapSz = Mathf.ClosestPowerOfTwo(AfMapSz);
		}

		SPSS = new SplatPrototype[TrTx.Length];
		Splats = SPSS.Length;
		Debug.Log("TRTX: "+TrTx.Length);
		Debug.Log("SPLT: "+SPSS.Length);
		
		for(int i = 0; i < Splats; i++){
			SPSS_.texture = TrTx*.Tex2D;*_

SPSS_.normalMap = TrTx*.Nml2D;
SPSS.tileSize = TrTx.TextSPD;
}
}*_

When the script is run I get an error that states at Line 59 (“SPSS_.texture = TrTx*.Tex2D;”)
NullReferenceException: Object reference not set to an instance of an object*_</em></em></em></em></em></em> <em><em><em><em><em><em>_*TerraAttachment.Start () (at Assets/Resources/Script/Terrain/TerrainPlus/TerraAttachment.cs:59)
Yet both the Debug.Log of both SPSS[] and TrTx[] states there are 3 items in the Arrays, and the inspector also shows the same.
TL;DR:
- Inspector shows the Array has items, the Debug Logs show the Arrays have items and yet I’m getting an error saying the array is empty? Any help would be great.*_

This turned out to be a very simple Fix, basically the SBSS (SplatPrototype) happened not to be initialized, to fix this issue:

		SPSS = new SplatPrototype[TrTx.Length];
		for(int i = 0; i < TrTx.Length; i++){
			SPSS_.texture = TrTx*.Tex2D;*_

SPSS_.normalMap = TrTx*.Nml2D;
SPSS.tileSize = TrTx.TextSPD;
}
Becomes
SPSS = new SplatPrototype[TrTx.Length];
for(int i = 0; i < TrTx.Length; i++){
SPSS = new SplatPrototype();
SPSS.texture = TrTx.Tex2D;
SPSS.normalMap = TrTx.Nml2D;
SPSS.tileSize = TrTx.TextSPD;
}*_