I’m getting some strange behaviour when using Odin’s button feature. I’m using it to instantiate a grid of gameobjects with a custom monobehaviour and add them to a list. They instantiate fine, however, when adding them to the list, it only adds them up to the first page of the list (the “pages” that Odin automatically separates lists into when drawn in the inspector). What’s weirder is when I clear the list and destroy all of the instantiated gameobjects and try again, it instantiates them all normally again, but this time it will add MORE of them to the list (but still not all). I’m not sure if this is an Odin specific issue but I’m wondering if there may be a serialization issue because whenever I do it for the first time, it only properly adds just enough for the first page of the list.
Here is the associated code for spawning:
public void InstantiateGrid()
{
battleGrid.tilemap.CompressBounds();
int x = 0;
int y = 0;
for (x = battleGrid.tilemap.cellBounds.min.x; x < battleGrid.tilemap.cellBounds.max.x; x++)
{
for (y = battleGrid.tilemap.cellBounds.min.y; y < battleGrid.tilemap.cellBounds.max.y; y++)
{
TilemapGridTile tilemapTile = battleGrid.tilemap.GetTile(new Vector3Int(x, y, 0)) as TilemapGridTile;
Vector3 position = battleGrid.grid.GetCellCenterWorld(new Vector3Int(x, y, 0));
GridTile ob = Instantiate(gridTileObject, battleGrid.tilemap.transform);
ob.Initialize(tilemapTile.Info, new Vector2Int(x, y));
ob.transform.position = battleGrid.tilemap.WorldToLocal(position);
battleGrid.AddGridTile(ob); //Adding to the 'problematic' list
}
}
}
And for clearing:
public void ClearGrid()
{
while (transform.GetChild(0).childCount > 0)
{
DestroyImmediate(transform.GetChild(0).GetChild(0).gameObject);
}
battleGrid.ClearInitialTiles(); //Method just for calling List.Clear()
battleGrid.ClearGridTiles();
}
Here is a video demonstrating:
Any help is appreciated!