dimanche 4 juillet 2021

In Unity, reordering child game objects randomly

I am making a board game. There is a grid. Grid has many tiles. Board image. Tiles are child game objects of grid. I want to reorder tiles randomly at the end of each level.

    foreach (GameObject tile in tileList)
    {
        tile.transform.SetSiblingIndex(UnityEngine.Random.Range(0, tileCount));
    }

I tried like this. Is this snippet of code correct?




Aucun commentaire:

Enregistrer un commentaire