ldtkgo icon indicating copy to clipboard operation
ldtkgo copied to clipboard

Empty Level.Layers when opening a 1.5.3 LDtk project

Open quasilyte opened this issue 2 years ago • 1 comments

I might be doing something wrong, but when I open a project, a level's layer list is empty.

I'm using LDtk version 1.5.3.

This is how I use ldtkgo:

p, err := ldtkgo.Open(*projectFilename)
	if err != nil {
		panic(err)
	}

	for _, level := range p.Levels {
		for _, layer := range level.Layers {
			// Never executed because Layers is [].
		}
	}
}

I can confirm that Level fields like Identifier are loaded correctly.

The Level has layers:

	"layerInstances": [
		{
			"__identifier": "BottomTiles",
			"__type": "Tiles",
			"__cWid": 32,
			"__cHei": 20,
			"__gridSize": 16,
			"__opacity": 1,
			"__pxTotalOffsetX": 0,
...

I'm not sure why they're not unmarshalled into the ldtkgo.Level.Layers.

Here is an LDtk project (it's just 1 level and a project file):

test.zip

quasilyte avatar Feb 10 '24 17:02 quasilyte

Hmm, I may have a clue. :D I'm using level files stored /outside/ of the project manifest. As far as I see, this library expects to find all level data inside the project file.

"externalLevels": true,

quasilyte avatar Feb 10 '24 18:02 quasilyte