改成这样
using UnityEngine;
using System.Collections;
public class ChessBoard : MonoBehaviour {
Coordinate[,] chessBoardPos;
void Start () {
chessBoardPos = new Coordinate[8,8];
chessBoardPos [1, 1] = new Coordinate ();
chessBoardPos[1,1].x= 1.111f;
}
}
你这样相当于
chessboardpos[1,1] = null;
chessboardpos[1,1].x = 1.111f
是空的咋赋值都会告诉你
Object reference not set to an instance of an object
是不是没有实例化