Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lightmaps disappear after playmode #2

Open
empika opened this issue Nov 6, 2017 · 2 comments
Open

Lightmaps disappear after playmode #2

empika opened this issue Nov 6, 2017 · 2 comments

Comments

@empika
Copy link

empika commented Nov 6, 2017

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

@lassade
Copy link
Owner

lassade commented Nov 7, 2017

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.

@empika
Copy link
Author

empika commented Nov 7, 2017

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();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants