Open empika opened 6 years ago
The BakedLigthingSpriteData depends on the editor to execute its function and then transfer the lightmap data to the sprintesrender, this data isn't serialized so it depends on the BakedLigthingSpriteData to set everything.
What you need to do is add an update method that only works in editor and if isn't playing like so:
// This method will execute at every editor update event since the class have the ExecuteInEditMode attribute
[Conditional("UNITY_EDITOR")]
void Update()
{
if (Application.isPlaying) return;
TransferLightmapData();
}
Try this and let me know if works.
Thanks for the swift reply.
That code didn't quite work, but sticking an [ExecuteInEditMode] property on the BakedLigthingSpriteData class and adding the following seems to fix it:
private void OnRenderObject()
{
if (!Application.isPlaying)
{
TransferLightmapData();
}
}
Hey,
Thanks for the excellent scripts!
I have an issue where lightmaps disappear from the SpriteRenderers after exiting play mode in the editor (they are still visible in play mode if started again). Retransferring the settings from the values cached in BakedLigthingSpriteData fixes the issue until the next time you play.
Any ideas what could be causing this?
Many thanks