次の構造体を宣言しました。
struct StartPositions
{
public Vector2 pacman;
public Vector2[] ghosts;
// Constructor accepts a Vector2, and an array of Vector2's.
public StartPositions(Vector2 pacmanPosIn, Vector2[] ghostsPosIn)
{
pacman = pacmanPosIn;
for(int a=0;a<ghostsPosIn.Length;a++)
{
ghosts[a] = ghostsPosIn[a];
}
}
}
ただし、ghosts フィールドを完全に割り当てる必要があるというコンパイラ エラーが発生します。私がやりたいことは、Vector2 を渡し、StartPositions オブジェクトを作成するときに Vector2 配列を渡し、その配列のコピーを作成することです。
どうすればこれを正しく行うことができますか?