laurenth-personal / lightmap-switching-tool

Tool that allows switching different baked lightmap sets on a unity scene at runtime.
MIT License
657 stars 88 forks source link

Error when trying to load lightprobes for scenario #29

Closed vlastan closed 3 years ago

vlastan commented 3 years ago

Hi, i am having issues with the use of lightprobes. The way i understood, is that the light probe groups have to be contained in the main scene with the static geometry. However after i build and store a scenario and entering play mode, the scenario isn't correctly loaded and errors pops up in the console.

What exactly is the workflow related to lightprobes?

laurenth-personal commented 3 years ago

Hi, the workflow should be as what you describe, there are no extra steps for light probes to be taken into account. Can you copy and paste here the error you're getting ? What unity version are you on ? Does it work for you in my mini test project ?

vlastan commented 3 years ago

I get two warnings. First one: Warning, error when trying to load lightprobes for scenario 0 UnityEngine.Debug:LogWarning(Object) LevelLightmapData:LoadLightProbes(Int32) (at C:/Users/giovanni/Desktop/Iside/Assets/LightmapSwitchingTool/Runtime/LevelLightmapData.cs:251)

d__22:MoveNext() (at C:/Users/giovanni/Desktop/Iside/Assets/LightmapSwitchingTool/Runtime/LevelLightmapData.cs:175) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) LevelLightmapData:LoadLightingScenario(Int32) (at C:/Users/giovanni/Desktop/Iside/Assets/LightmapSwitchingTool/Runtime/LevelLightmapData.cs:77) LightingManager:Awake() (at C:/Users/giovanni/Desktop/Iside/Assets/Scripts/LightingManager.cs:15) Second one: Warning, error when trying to load lightprobes for scenario 0 UnityEngine.Debug:LogWarning(Object) LevelLightmapData:LoadLightProbes(Int32) (at C:/Users/giovanni/Desktop/Iside/Assets/LightmapSwitchingTool/Runtime/LevelLightmapData.cs:251) LevelLightmapData:LoadLightingScenario(Int32) (at C:/Users/giovanni/Desktop/Iside/Assets/LightmapSwitchingTool/Runtime/LevelLightmapData.cs:88) LightingManager:Awake() (at C:/Users/giovanni/Desktop/Iside/Assets/Scripts/LightingManager.cs:15)
laurenth-personal commented 3 years ago

Does it fail if you do the same steps in the project provided here ?

laurenth-personal commented 3 years ago

Oh I just noticed one thing : you're calling the script on Awake but the light probes arrays are prepared on Start in LevelLightmapData line 92. You could try chaning Start to Awake there.

laurenth-personal commented 3 years ago

Hi, I just noticed the "PrepareLightProbeArrays" step that was called on Start was no longer needed. So I updated the code and now you should be able to call LoadLightingScenario on Awake.

laurenth-personal commented 3 years ago

Please let me know if this works for you :)