static public void SwapAssociatedTiles(HiddenTileBehavior tileBack, HiddenTileBehavior otherTileBack) { // swap associated tiles GameObject tmp = tileBack.tileAssociated; tileBack.tileAssociated = otherTileBack.tileAssociated; otherTileBack.tileAssociated = tmp; TileBehavior tile = tileBack.tileAssociated.GetComponent <TileBehavior>(); TileBehavior otherTile = otherTileBack.tileAssociated.GetComponent <TileBehavior>(); // swap tiles positions Vector3 tempPos = tile.transform.position; tile.transform.position = otherTile.transform.position; otherTile.transform.position = tempPos; // swap tiles indices int tmpIndex = tile.index; tile.index = otherTile.index; otherTile.index = tmpIndex; // finally update cells and swap rotation int rotation = tile.tileRotation; int otherRotation = otherTile.tileRotation; tile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(0); otherTile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(0); tile.updateTileCells(); otherTile.updateTileCells(); tile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(otherRotation); otherTile.GetComponent <TileBehaviorIHM>().goToDesiredOrientation(rotation); }