How do i use my setter?

This is a script that is attached to multiple “Chess Pieces” in my game and im calling the setter here.

public class GameManagerChess : MonoBehaviour {

 public GameObject colliderObj=null;
 public GameManage GameManager;
 public int pieceIndex;
 public int posX;
 public int posY;
 // Use this for initialization
 void Start () {
     this.transform.position = new Vector3(colliderObj.transform.position.x,colliderObj.transform.position.y,colliderObj.transform.position.z);
     addToBoardPiecesTable ();
 }
 void addToBoardPiecesTable(){
     GameManager = gameObject.GetComponent<GameManage>();
     int pos = pieceIndex * int.Parse(this.tag);
     GameManager.setBoardPieces (posX,posY,pos);
 }

And this is the setter in the GameManage class

public void setBoardPieces(int posX,int posY,int pos){ _boardPieces[posX,posY]=pos; }

There is a “NullReferenceException: Object reference not set to an instance of an object” error in this line GameManager.setBoardPieces (posX,posY,pos);

Im trying to fill a table in the GameManage class by getting info from all the chess pieces. Im new to C# and unity3d.

First, I recommend your variable names start with a lowercase so that there is a clear distinction between GameManager the class, and GameManager the variable.

Secondly, this

GameManager = gameObject.GetComponent<GameManage>();

assumes that the GameManager script is attached to the same game object the GameManagerChess is. Is this true?

If not, take a look at this short tutorial: GetComponent