BVG.Board.InstantiateSquare C# (CSharp) Method

InstantiateSquare() private method

Instantiate a given square prefab with the given coordinates. Set all the right properties and add it to the board.
private InstantiateSquare ( GameObject squarePrefab, IntVector2 boardPosition ) : void
squarePrefab UnityEngine.GameObject Square prefab.
boardPosition IntVector2 The position on the board to instantiate to.
return void
		private void InstantiateSquare(GameObject squarePrefab, IntVector2 boardPosition) {
			// instantiate the square and size it correctly
			GameObject square = Instantiate<GameObject>(squarePrefab);
			square.transform.SetParent(transform, false);
			RectTransform squareRectTransform = square.transform as RectTransform;
			squareRectTransform.sizeDelta = cellSize;

			// assign collider properties
			BoxCollider2D collider = square.GetComponent<BoxCollider2D>();
			if (collider == null) {
				Debug.LogErrorFormat("Generated square at {0} does not have a box collider 2d component.", boardPosition);
				return;
			}
			collider.size = cellSize;

			// assign tile properties
			Tile tile = square.GetComponent<Tile>();
			if (tile == null) {
				Debug.LogErrorFormat("Generated square at {0} does not have a tile component.", boardPosition);
				return;
			}
			tile.Coordinates = boardPosition;
			tile.SetParentBoard(this);

			// add to the board
			board[boardPosition.x, boardPosition.y] = square;
		}