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

Workaround for Build and Store #13

Open
markvitapoly opened this issue Oct 29, 2017 · 3 comments
Open

Workaround for Build and Store #13

markvitapoly opened this issue Oct 29, 2017 · 3 comments
Assignees

Comments

@markvitapoly
Copy link

markvitapoly commented Oct 29, 2017

Hi, I am using Unity 2017.2.0f3 and the lightmaps are messed up after baking. I see this comment:

The "Build" and the "Store" steps have not been merged because in some builds ( seen in 5.5.0f1 ) the lightmaps don't load correctly after baking

I have a few lightmaps set up for a particular scene so I modified the script to build and store them all overnight. Is there a workaround to this existing issue? I've tired something like this:

    Debug.Log("Building Lights: " + ScenarioName);
    yield return BuildLightingAsync(ScenarioName);

    EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath(BaseScenePath + "/" + ScenarioName + ".unity"), true);

    Debug.Log("Enter Play Mode");
    EditorApplication.ExecuteMenuItem("Edit/Play");

    ///////// The below code doesn't get executed anymore once Play mode starts. Workarounds?
    Debug.Log("Waiting 30 seconds");
    yield return new WaitForSeconds(30);              

    Debug.Log("Exit Play Mode");
    EditorApplication.ExecuteMenuItem("Edit/Play");

    Debug.Log("Storing Light");
    StoreLightmapInfos(storeIndex);

Thanks!

@laurenth-personal
Copy link
Owner

Hi ! As this is not an officially supported unity workflow, I can't really ask for a fix on unity side. Storing right after build however works on SOME unity builds, but I believe in the latest ones it's consistently broken, so I am interested in providing a reliable workaround. I'll try what you suggest and see if I can make it work. Thanks for the suggestion

@markvitapoly
Copy link
Author

Just want to let you know that I was able to make it work with some hacks. I set some PlayerPref variables indicating that it's light building mode that triggered the play event. Then when in Play mode, it will wait a bit and then disable play mode updating the PlayerPref variables. In the editor script, I am also listening to EditorApplication.playModeStateChanged so I can catch when Unity stops playing and store the lightmaps. It'll continue to do this until all the lightmaps are finished.

It works, but it's pretty hacky. So, I think Unity core should officially support your project because using this project was how I got assetbundles to dynamically load lightmaps properly.

@laurenth-personal
Copy link
Owner

Trying a similar workaround ^^ if it works I'll put it in a branch. In the meantime I'll see if I can reproduce the bug with messed up lightmaps without using the script so I can report it.

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

No branches or pull requests

2 participants