public void OnLoad(string data) { SaveData saveData = JsonUtility.FromJson <SaveData>(data); if (saveData != null) { for (int i = 0; i < saveData.actions.Count; i++) { ScriptableTileBase tileBase = ScriptableAssetDatabase.GetAsset(saveData.actions[i].Guid) as ScriptableTileBase; if (tileBase != null) { SetTile(saveData.actions[i].Location, saveData.actions[i].Tag, tileBase); } else { Debug.Log("Tried to obtain null tilebase data"); } } } }
public void SetTile(Vector3Int location, string tilemapName, ScriptableTileBase tileBase) { isDirty = true; Tilemap tileMap; tileMaps.TryGetValue(tilemapName, out tileMap); if (tileMap != null) { tileMap.SetTile(location, tileBase); saveData.actions.Add(new TileManipulationAction() { Guid = tileBase.GetGuid(), Location = location, Tag = tilemapName }); } else { Debug.Log($"Failed attempt to set tilemap with name: {tilemapName}"); } }