Skip to content

Commit

Permalink
fix: Separate levels checking null for artifact assets in case it's n…
Browse files Browse the repository at this point in the history
…ever generated by the project importer
  • Loading branch information
Cammin committed May 12, 2024
1 parent 9121365 commit dbded97
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Assets/LDtkUnity/Editor/ScriptedImporter/LDtkLevelImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ protected override void Import()
CacheSchemaDefs(_projectJson, _levelJson);
Profiler.EndSample();

Profiler.BeginSample("InitializeDefinitionObjectsFromLevel");
var tilesets = MakeTilesetDict(_projectImporter, _projectJson);
DefinitionObjects.InitializeFromLevel(_projectImporter.GetArtifactAssets()._definitions, tilesets);
Profiler.BeginSample("InitializeDefinitionObjects");
if (!InitializeDefinitionObjects())
{
Profiler.EndSample();
FailImport();
return;
}
Profiler.EndSample();

Profiler.BeginSample("BuildLevel");
Expand All @@ -106,6 +110,18 @@ protected override void Import()
Profiler.EndSample();
}

private bool InitializeDefinitionObjects()
{
LDtkArtifactAssets artifacts = _projectImporter.GetArtifactAssets();
if (artifacts == null)
{
return false;
}
var tilesets = MakeTilesetDict(_projectImporter, _projectJson);
DefinitionObjects.InitializeFromLevel(artifacts._definitions, tilesets);
return true;
}

private void BuildLevel()
{
var preAction = new LDtkAssetProcessorActionCache();
Expand Down

0 comments on commit dbded97

Please sign in to comment.