/// <summary> /// Clears a PlacedTileObject at a given layer and position. /// </summary> /// <param name="map"></param> /// <param name="layer"></param> /// <param name="subLayerIndex"></param> /// <param name="position"></param> public void ClearTileObject(TileMap map, TileLayer layer, int subLayerIndex, Vector3 position) { map.ClearTileObject(layer, subLayerIndex, position); }
/// <summary> /// Loads all TileMaps into the manager. The softload parameter determines if saved objects should be /// new created, or only reinitalized. /// </summary> /// <param name="softLoad"></param> public void LoadAll(bool softLoad) { if (tileObjectSOs == null) { tileObjectSOs = Resources.FindObjectsOfTypeAll <TileObjectSO>(); } if (softLoad) { mapList.Clear(); } else { DestroyMaps(); } ManagerSaveObject saveMapObject = SaveSystem.LoadObject <ManagerSaveObject>(saveFileName); if (saveMapObject == null) { Debug.Log("No saved maps found. Creating default one."); CreateEmptyMap(); mapList[mapList.Count - 1].IsMain = true; SaveAll(); return; } foreach (MapSaveObject s in saveMapObject.saveObjectList) { TileMap map = null; if (softLoad) { bool found = false; for (int i = 0; i < transform.childCount; i++) { var child = transform.GetChild(i); if (child.name == s.mapName) { map = child.GetComponent <TileMap>(); found = true; } } if (!found) { Debug.LogWarning("Map was not found when reinitializing: " + s.mapName); continue; } map.Setup(s.mapName); map.Load(s, true); Debug.Log("Tilemaps soft loaded"); } else { map = AddTileMap(s.mapName); map.Load(s, false); Debug.Log("Tilemaps loaded from save"); } mapList.Add(map); } }
/// <summary> /// Sets a new TileObjectSO via name at a map for a given position and direction. Wrapper function for TileMap.SetTileObject(). /// </summary> /// <param name="map"></param> /// <param name="subLayerIndex"></param> /// <param name="tileObjectSOName"></param> /// <param name="position"></param> /// <param name="dir"></param> public void SetTileObject(TileMap map, int subLayerIndex, string tileObjectSOName, Vector3 position, Direction dir) { SetTileObject(map, subLayerIndex, GetTileObjectSO(tileObjectSOName), position, dir); }