private void Start() { gameObjectTilemap = new GameObjectTilemap(); InitializeNameToSurfaceLayer(); painters = new List <MultithreadedSurfacePainter>(); VisualizingManager.Instance.OnOsmFileParsed.AddListener(VisualizeTile); VisualizingManager.Instance.OnTileRemoved.AddListener(gameObjectTilemap.RemoveTile); }
public void ExtractPatterns() { if (!_tilemap) _tilemap = GetComponent<GameObjectTilemap>(); _patterns.Clear(); Patterns.Clear(); foreach (var pos in _tilemap.Bounds.allPositionsWithin) { var tile = _tilemap.GetTile(pos); if(!tile) continue; var pattern = GetOrCreatePattern(tile); for (var idx = 0; idx < NeighborOffset.Length; idx++) { var neighborPos = pos + NeighborOffset[idx]; var neighborTile = _tilemap.GetTile(neighborPos); if (!neighborTile) { if (IncludeEmptyTile) { var emptyPattern = GetOrCreateEmptyPattern(); pattern.Neighbors[idx].Add(emptyPattern); emptyPattern.Neighbors[NeighborOffset.IndexOf(-NeighborOffset[idx])].Add(pattern); } continue; } var neighborPattern = GetOrCreatePattern(neighborTile); pattern.Neighbors[idx].Add(neighborPattern); } } foreach(var pattern in _patterns.Values) Patterns.Add(pattern); if (IncludeEmptyTile) Patterns.Add(GetOrCreateEmptyPattern()); }
private void Awake() { _tilemap = GetComponent <GameObjectTilemap>(); }
private void Start() { gameObjectTilemap = new GameObjectTilemap(); VisualizingManager.Instance.OnOsmFileParsed.AddListener(VisualizeTile); VisualizingManager.Instance.OnTileRemoved.AddListener(gameObjectTilemap.RemoveTile); }