Cammin / LDtkToUnity

Unity importer for the LDtk level editor
https://cammin.github.io/LDtkToUnity
MIT License
388 stars 39 forks source link

ILDtkImportedLevel's OnLDtkImportLevel not invoked #37

Closed bennett-harvey closed 2 years ago

bennett-harvey commented 2 years ago

I specified a level prefab for an LDtk file, and that prefab had a behavior that implemented the ILDtkImportedLevel interface, but its OnLDtkImportLevel function was never called. On the other hand, the same script also implemented ILDtkImportedFields, and its OnLDtkImportFields function was called.

I believe it can be fixed by swapping line 159 and line 162 of Editor/LDtkBuilderLevel.cs (though I've only briefly looked at the source code, so I'm not 100% sure).

Before:

if (addedFields)
{
    LDtkInterfaceEvent.TryEvent<ILDtkImportedLevel>(monoBehaviours, levelComponent => levelComponent.OnLDtkImportLevel(level));
}

LDtkInterfaceEvent.TryEvent<ILDtkImportedFields>(monoBehaviours, levelComponent => levelComponent.OnLDtkImportFields(lDtkFields));

After:

if (addedFields)
{
    LDtkInterfaceEvent.TryEvent<ILDtkImportedFields>(monoBehaviours, levelComponent => levelComponent.OnLDtkImportFields(lDtkFields));
}

LDtkInterfaceEvent.TryEvent<ILDtkImportedLevel>(monoBehaviours, levelComponent => levelComponent.OnLDtkImportLevel(level));
Cammin commented 2 years ago

Yes, this is 100% an oversight that I've also caught wind of from another report on the discord server. I'm keeping tabs on it and the fix will be in a coming update. I'll let you know back here when the next update is released with this fix. Also, expect lots of performance optimizations in the next update 🙂

Cammin commented 2 years ago

Hi, this issue should be fixed from the new update from today. (3.1.0) I'll close this, but if you have any additional issues about this then feel free to reopen 🙂