unity3d – Need to deepcopy information from a monobehaviour C# Unity

could someone please help me? I’m trying to make an AI for my tile-based game in Unity but I’ve run into an issue that nobody seems to be able to figure out.

What I want to do is copy all the information of a Tile Monobehaviour and then use it to generate all the possible moves. Then I can score them and find the best one with minimax. Therefore I need a DEEP COPY of the information to use.

Problem is, apparently you can’t deep copy a mono behaviour. But I really need to be able to do it. Does anyone have ideas for how I can get around this?

public Tile[,] updateCurrentTiles()
{
    Tile[,] tileArray = new Tile[GridManager.Instance._width, GridManager.Instance._height];
    foreach (Tile tile in GridManager.Instance._activeTiles)
    {
        tileArray[tile.Location.x, tile.Location.y] = tile.Clone();
    }
    return tileArray;
}

If you need more information please ask. Thank you

Read more here: Source link