can't instantiate gameobject
I have made a button to spawn an object in unity, the only problem is it doesn't spawn that object, i have the script referencing an array from another script which it does actually have a gameobject stored in, but for some reason it is still giving me a null reference error,
below is my code
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class Mspawn : MonoBehaviour { public Button Mbutton; private BoardManager boardManger; // Use this for initialization void Start () { boardManger = GetComponent ();
 }
 
 // Update is called once per frame
 void Update () {
 
 }
 void OnEnable(){
     Mbutton.onClick.AddListener (SpawnM);
 }
 void SpawnM()
 {
     Instantiate (boardManger.PlayerUnits[3], new Vector3 (1, 1, 0f), Quaternion.identity);
 }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                