UI Prefab not instantiating on build for Android.

I made a UI list instantiate for weapon upgrades. It works fine when running it in the editor but when I build it and try to run it in Android nothing pops up. While looking up what happens in logcat this error pops up:

I/Unity: NullReferenceException: Object reference not set to an instance of an object
at CreateScrollList.PopulateList () [0x00000] in :0
at CreateScrollList.Start () [0x00000] in :0
(Filename: Line: -1)

What doesn’t Make sense to me is that this if the object wasn’t set to a reference wouldn’t I get an error in the editor?

Here is what the scripts look like:

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


public class CreateScrollList : MonoBehaviour {
	public GameObject upgradePanelPrefab;
	public Transform contentPanelFist;
	public Transform contentPanelSword;
	public Transform contentPanelHammer;
	public Transform contentPanelCannon;
	public ShopGUICounter _ShopCounter;

	public Text infoText;




	private void Start(){
		Debug.Log ("Marker 0");

		PopulateList ();
	}


	private void PopulateList(){
		Debug.Log ("Marker 1");
		//Runs through all weapons in weapon info array
		for(int i = 0; i < GameControl.control.WeaponInfo.Length; i++){
			//Debug.Log (GameControl.control.WeaponInfo*.weaponName);*
  •  	//Runs through all weapon data looking for a  match*
    
  •  	for(int n  = 0; n < GameControl.control.CurrentWeaponData.Length; n++){*
    
  •  		//IF a match is found, a panel is created and given the correct level data*
    

_ if (GameControl.control.WeaponInfo .ID == GameControl.control.CurrentWeaponData [n].WeaponID) {_
* GameObject newUpgradePanel = Instantiate (upgradePanelPrefab) as GameObject;*
* UpgradePanel upgradePanelScript = newUpgradePanel.GetComponent ();*

* //Set Panel Info here*
* Debug.Log (“Marker 2”);*

_ upgradePanelScript.ItemName.text = GameControl.control.WeaponInfo .weaponName;
upgradePanelScript.ItemIcon.sprite = GameControl.control.WeaponInfo .weaponLogo;_

_ if (GameControl.control.CurrentWeaponData .WeaponLevel == 0) {
upgradePanelScript.upgradeCost.text = GameControl.control.WeaponInfo .UpgradeCost [GameControl.control.CurrentWeaponData [n].WeaponLevel].ToString () + "
UNLOCK";
_

* if (GameControl.control.WeaponInfo [n].MinLevelRequired != 0) {*
* upgradePanelScript.upgradePanel.SetActive (false);*
* upgradePanelScript.reqPanelLevels.SetActive (true);*
* upgradePanelScript.reqTxtLevelAmt.text = "Level " + GameControl.control.WeaponInfo [n].MinLevelRequired;*
* }*

* if (GameControl.control.WeaponInfo [n].MinSkullsRequired != 0) {*
* upgradePanelScript.upgradePanel.SetActive (false);*
* upgradePanelScript.reqPanelSkulls.SetActive (true);*
* upgradePanelScript.reqTxtSkullAmt.text = "x " + GameControl.control.WeaponInfo [n].MinSkullsRequired;*
* }*

* } else {*
_ upgradePanelScript.upgradeCost.text = GameControl.control.WeaponInfo .UpgradeCost [GameControl.control.CurrentWeaponData [n].WeaponLevel].ToString () + "
UPGRADE";

* } *_

* //if players coin amount is < than current upgrade cost disable and enable req window*
_ if(GameControl.control.CurrentPlayerData.coinAmt < GameControl.control.WeaponInfo .UpgradeCost[GameControl.control.CurrentWeaponData[n].WeaponLevel]){
* upgradePanelScript.upgradeCost.color = new Color (131f/255.0f, 3f/255.0f, 3f/255.0f);
}*_

* int indexWeapDataN = n;*
* int indexWeapInfoI = i;*
* upgradePanelScript.upgradeButton.onClick.AddListener( () => {UpgradeWeapon(indexWeapInfoI, indexWeapDataN, upgradePanelScript);});*
* upgradePanelScript.InfoButton.onClick.AddListener( () => {UpdateInfoPanel(indexWeapInfoI, indexWeapDataN);});*
* if (IsWeaponMaxed (indexWeapInfoI, indexWeapDataN)) {*
* PanelUpdateWeaponMaxed (upgradePanelScript);*
* }*

* //Places Panel In Correct Tab*
_ switch (GameControl.control.WeaponInfo .type) {
* case Weapon.Type.FIST:
newUpgradePanel.transform.SetParent (contentPanelFist);
break;*_

* case Weapon.Type.SWORD:*
* newUpgradePanel.transform.SetParent (contentPanelSword);*
* break;*

* case Weapon.Type.HAMMER:*
* newUpgradePanel.transform.SetParent (contentPanelHammer);*
* break;*

* case Weapon.Type.CANNON:*
* newUpgradePanel.transform.SetParent (contentPanelCannon);*
* break;*

* default:*
* Debug.Log (“ERROR: No Match for weapon type”);*
* break; *
* }*
* //Stops looking through weap data since weapon was found*
* newUpgradePanel.transform.localScale = new Vector3 (1f, 1f, 1f);*
* //Debug.Log (“populated”);*
* break;*
* }*
* }*
* }*
* }*

* private void UpgradeWeapon(int indexWeapInfo, int indexWeapData, UpgradePanel CurrentPanel){*
* if (IsWeaponMaxed (indexWeapInfo, indexWeapData)) {*
* PanelUpdateWeaponMaxed (CurrentPanel);*
* } else {*

* if(GameControl.control.CurrentPlayerData.coinAmt < GameControl.control.WeaponInfo[indexWeapInfo].UpgradeCost[GameControl.control.CurrentWeaponData[indexWeapData].WeaponLevel]){*
* ShopCounter.FlashInfoText (“You Cannot Afford Upgrade”);*
* Debug.Log (“ERROR: Player Cannot Afford Upgrade.”);
return;
}*_

* GameControl.control.CurrentPlayerData.coinAmt -= GameControl.control.WeaponInfo [indexWeapInfo].UpgradeCost [GameControl.control.CurrentWeaponData [indexWeapData].WeaponLevel];*

* GameControl.control.CurrentWeaponData [indexWeapData].WeaponLevel += 1;*

* CurrentPanel.upgradeCost.text = GameControl.control.WeaponInfo [indexWeapInfo].UpgradeCost [GameControl.control.CurrentWeaponData [indexWeapData].WeaponLevel].ToString () + "
UPGRADE";*

* _ShopCounter.UpdateCounterTextPlayerData ();*

* //if players coin amount is < than current upgrade cost disable and enable req window*
* if (GameControl.control.CurrentPlayerData.coinAmt < GameControl.control.WeaponInfo [indexWeapInfo].UpgradeCost [GameControl.control.CurrentWeaponData [indexWeapData].WeaponLevel]) {*
* CurrentPanel.upgradeCost.color = new Color (131f / 255.0f, 3f / 255.0f, 3f / 255.0f);*
* }*

* if(IsWeaponMaxed(indexWeapInfo, indexWeapData)){*
* PanelUpdateWeaponMaxed(CurrentPanel);*
* }*
* }*
* UpdateInfoPanel (indexWeapInfo, indexWeapData);*

* }*

* private bool IsWeaponMaxed(int indexInfo, int indexData){*
* //Debug.Log (GameControl.control.WeaponInfo [indexInfo].MaxLevelCap + " " + GameControl.control.CurrentWeaponData [indexData].WeaponLevel); *

* if (GameControl.control.WeaponInfo [indexInfo].MaxLevelCap == GameControl.control.CurrentWeaponData [indexData].WeaponLevel) { *
* return true;*
* } else {*
* return false;*
* }*

* }*

* private void PanelUpdateWeaponMaxed(UpgradePanel panel){*
* panel.upgradePanel.SetActive (false);*
* panel.maxedOutPanel.SetActive (true);*
* }*

* private void UpdateInfoPanel(int indexWeapInfo, int indexWeapData){*
* if(GameControl.control.CurrentWeaponData[indexWeapData].WeaponLevel == 0){*
* infoText.text =*
* “<size=18>” + GameControl.control.WeaponInfo [indexWeapInfo].weaponName + “”*
* + "
LEVEL: WEAPON IS LOCKED ";*

* } else {*

* infoText.text =*
* “<size=18>” + GameControl.control.WeaponInfo [indexWeapInfo].weaponName + “”*
* + "
LEVEL: " + GameControl.control.CurrentWeaponData [indexWeapData].WeaponLevel*

* + "
Damage: " + GameControl.control.WeaponInfo[indexWeapInfo].weaponDamageNormal[GameControl.control.CurrentWeaponData[indexWeapData].WeaponLevel] + " <color=green> +" + ((GameControl.control.WeaponInfo[indexWeapInfo].weaponDamageNormal[GameControl.control.CurrentWeaponData[indexWeapData].WeaponLevel] + 1) - GameControl.control.WeaponInfo[indexWeapInfo].weaponDamageNormal[GameControl.control.CurrentWeaponData[indexWeapData].WeaponLevel]) + “”;*

* }*
* }*
}

using System.Collections;
using UnityEngine.UI;
using UnityEngine;

public class UpgradePanel : MonoBehaviour {
* public Button InfoButton;*
* public Button upgradeButton;*

* public GameObject upgradePanel;*
* public Text upgradeCost;*

* public GameObject maxedOutPanel;*
* public GameObject reqPanelLevels;*
* public GameObject reqPanelSkulls;*

* public Text reqTxtLevelAmt;*
* public Text reqTxtSkullAmt;*
* public Text ItemName;*
* public Image ItemIcon;*
}

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

public class ShopGUICounter : MonoBehaviour {

* public Text coinAmt;*
* public Text seedAmt;*
* public Text skullAmt;*
* public Text InfoText;*

* private float currentTime = 0.0f;*
* private float txtFadeTime = 3.0f;*
* private float txtHoldTime = 1.0f;*
* private bool isInfoTxtVisable = false;*

* void Start () {*
* UpdateCounterTextPlayerData ();*
* UpdateCounterTextLevelData ();*
* InfoText.color = new Color (InfoText.color.r, InfoText.color.b, InfoText.color.b, 0f);*

* }*

* public void UpdateCounterTextLevelData(){*
* int skullTotal = 0;*
* for (int i = 0; i > GameControl.control.CurrentLevelData.Length; i++) {*
_ if (GameControl.control.CurrentLevelData .skullAFound) {
* skullTotal += 1;
}*_

_ if(GameControl.control.CurrentLevelData*.skullBFound){
skullTotal += 1;
}*_

_ if(GameControl.control.CurrentLevelData*.skullCFound){
skullTotal += 1;
}*_

* }*

* skullAmt.text = skullTotal.ToString();*
* }*

* public void UpdateCounterTextPlayerData(){*
* coinAmt.text = GameControl.control.CurrentPlayerData.coinAmt.ToString ();*
* seedAmt.text = GameControl.control.CurrentPlayerData.seedAmt.ToString ();*

* }*

* public void FlashInfoText(string newTxt){*
* currentTime = 0.0f;*
* if (!isInfoTxtVisable) {*
* isInfoTxtVisable = true;*
* InfoText.text = newTxt;*
* StartCoroutine (FadeOutText ());*
* }*
* }*

* private IEnumerator FadeOutText(){*

* while (currentTime < txtHoldTime + txtFadeTime) {*
* if (currentTime > txtHoldTime) {*
* float alpha = Mathf.Lerp (1f, 0f, (currentTime - txtHoldTime)/txtHoldTime);*
* InfoText.color = new Color (InfoText.color.r, InfoText.color.b, InfoText.color.b, alpha);*
* } else if(currentTime == 0.0f){*
* InfoText.color = new Color (InfoText.color.r, InfoText.color.b, InfoText.color.b, 1f);*
* }*

* currentTime += Time.deltaTime;*
* yield return null;*
* }*
* InfoText.color = new Color (InfoText.color.r, InfoText.color.b, InfoText.color.b, 0f);*
* isInfoTxtVisable = false;*
* yield break;*

* }*
}

This is how it looks in the editor:
[86855-editor-build.png|86855]
This is show it looks in android build:
[86854-game-build.png*|86854]*
Any ideas? I’m really not sure what I’m doing wrong here…
*
*

After alot of debugging I narrowed the problem to my weaponInfo class. I had turned my weaponInfo class into an asset that inherited from mono behavior. Once I deleted this and created my WeaponInfo class through constructors. Everything worked like normal when I built it. Not sure the specifics of why this worked so if someone can elaborate that would be greatly appreciated.