diff --git a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkLevelImporter.cs b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkLevelImporter.cs index 32beb05a7..67f512fff 100644 --- a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkLevelImporter.cs +++ b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkLevelImporter.cs @@ -85,7 +85,7 @@ protected override void Import() Profiler.EndSample(); Profiler.BeginSample("CacheArtifactsAsset"); - _projectImporter.TryCacheArtifactsAsset(); + _projectImporter.TryCacheArtifactsAsset(Logger); Profiler.EndSample(); Profiler.BeginSample("CacheDefs"); diff --git a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkProjectImporter.cs b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkProjectImporter.cs index 9e3220075..69d85dd80 100644 --- a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkProjectImporter.cs +++ b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkProjectImporter.cs @@ -312,12 +312,8 @@ public Sprite GetBackgroundArtifact(Level level) Logger.LogError($"Tried retrieving a background from the importer's artifacts, but was null: \"{assetName}\""); return asset; } - - - - - public void TryCacheArtifactsAsset() + public void TryCacheArtifactsAsset(LDtkDebugInstance logger) { if (_backgroundArtifacts != null) { @@ -327,7 +323,7 @@ public void TryCacheArtifactsAsset() _backgroundArtifacts = AssetDatabase.LoadAssetAtPath(assetPath); if (_backgroundArtifacts == null) { - Logger.LogError($"Artifacts was null during the import, this should never happen. Does the sub asset not exist for \"{assetPath}\"?"); + logger.LogError($"Artifacts was null during the import, this should never happen. Does the sub asset not exist for \"{assetPath}\"?"); } } } diff --git a/Assets/LDtkUnity/Runtime/Tools/Bank/LDtkDictionaryUId.cs b/Assets/LDtkUnity/Runtime/Tools/Bank/LDtkDictionaryUId.cs index 026e61932..35eb385f6 100644 --- a/Assets/LDtkUnity/Runtime/Tools/Bank/LDtkDictionaryUId.cs +++ b/Assets/LDtkUnity/Runtime/Tools/Bank/LDtkDictionaryUId.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; namespace LDtkUnity { @@ -42,10 +43,23 @@ private void CacheLayerDefs(LayerDefinition[] layerDefs) { TryAdd(layerDefs); - IntGridValueGroupDefinition[] groupDefs = layerDefs.SelectMany(p => p.IntGridValuesGroups).ToArray(); - if (!groupDefs.IsNullOrEmpty()) + List defs = new List(); + foreach (LayerDefinition layerDef in layerDefs) { - TryAdd(groupDefs); + //if it's an old json value + if (layerDef.IntGridValuesGroups == null) + { + continue; + } + foreach (IntGridValueGroupDefinition group in layerDef.IntGridValuesGroups) + { + defs.Add(group); + } + } + + if (!defs.IsNullOrEmpty()) + { + TryAdd(defs.ToArray()); } } }