Try changing setting CompositeCollider2D.GenerationType to Synchronous from Manual.
Answer2.
Try waiting 1 frame after updating tilemap content.
using UnityEngine;
using UnityEngine.Tilemaps;
using System.Collections;
public class Playground : MonoBehaviour {
[SerializeField] private TileBase tile;
[SerializeField] private Tilemap tilemap;
private IEnumerator Start()
{
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 3; y++)
{
tilemap.SetTile(new Vector3Int(x, y, 0), tile);
}
}
yield return new WaitForEndOfFrame(); // need this!
tilemap.GetComponent<CompositeCollider2D>().GenerateGeometry();
yield return new WaitForEndOfFrame();
}
}
Above code can update collider with dynamic tile generation.
But, if we remove “// need this!” line, collder can not update.