public void JsonDeserializeEntityInstance() { TextAsset jsonProject = TestJsonLoader.LoadJson(TestJsonLoader.MOCK_ENTITY_INSTANCE); //try deserializing entity LDtkDataEntity entity = JsonConvert.DeserializeObject <LDtkDataEntity>(jsonProject.text); }
public void JsonDeserializeProject() { TextAsset jsonProject = TestJsonLoader.LoadJson(BASIC_PROJECT); Assert.NotNull(jsonProject, "Unsuccessful acquirement of json text asset"); //attempt deserializing entire project LDtkDataProject project = LDtkToolProjectLoader.LoadProject(jsonProject.text); }
public void GetLevelBounds() { const string lvlName = "Level"; TextAsset jsonProject = TestJsonLoader.LoadGenericProject(); LDtkDataProject project = LDtkToolProjectLoader.LoadProject(jsonProject.text); LDtkDataLevel level = project.levels.FirstOrDefault(p => p.identifier == lvlName); LDtkDataLayer layer = level.layerInstances.FirstOrDefault(p => p.IsIntGridLayer); Bounds bounds = layer.LayerUnitBounds; Debug.Log(bounds); }
public void GetCorrectTileBits() { TextAsset mockTest = TestJsonLoader.LoadJson(MOCK_TILE); LDtkDataTile[] tiles = JsonConvert.DeserializeObject <LDtkDataTile[]>(mockTest.text); foreach (LDtkDataTile tile in tiles) { Debug.Log($"Tile: {tile.FlipX}, {tile.FlipY}"); } Assert.IsTrue(tiles[0].FlipX == false && tiles[0].FlipY == false); Assert.IsTrue(tiles[1].FlipX == true && tiles[1].FlipY == false); Assert.IsTrue(tiles[2].FlipX == false && tiles[2].FlipY == true); Assert.IsTrue(tiles[3].FlipX == true && tiles[3].FlipY == true); }
private void DeserializeField(string key) { TextAsset fieldAsset = TestJsonLoader.LoadJson($"/LDtkMockField_{key}.json"); //try deserializing field LDtkDataField field = JsonConvert.DeserializeObject <LDtkDataField>(fieldAsset.text); string identifier = field.__identifier; string type = field.__type; string[] values = field.__value; Debug.Log($"identifier: {identifier}"); Debug.Log($"type: {type}"); Debug.Log($"values: [\"{string.Join("\"], [\"", values)}\"]\n(Square brackets don't actually exist in the string; is only visual and represents the string literals)"); Assert.False(values == null, "Field string array was null. Maybe this should not actually trigger failure."); }