Closed j9liu closed 6 months ago
To address the case where the original scene is unloaded, I pushed a commit that recreates the credit system if it's no longer valid on a tileset. Similar to Unreal, the tileset will recreate itself with respect to the new credit sytsem.
I thought the UI was bugged when the scene unloaded. But then I remembered that Cesium only works with the camera tagged "MainCamera". So I was deleting the MainCamera in the original scene, without assigning the tag to the new one. When you assign the tag to a new camera, the credits UI will reappear.
I took a look at the code and it all looks good to me. I haven't actually tried building/running/playing with it yet, though. I'll do that on Monday if Ashley doesn't beat me to it.
Thanks @j9liu! The changes look good to me, and seem to work correctly in my testing in the editor.
Thanks @azrogers! I noticed that the changelog hadn't been updated after the release, so I just pushed a commit to main to correct it.
Fixes #436. This PR prevents
CesiumCreditSystem
from being destroyed in its scene when other additive scenes are loaded / unloaded.To test, I created a new scene called "TestScene" and put a cube in it. I added it under the scenes in Build Settings, then created a script called "LoadUnloadScene.cs" with this code:
Then, I attached
LoadUnloadScene
as a component to theCesiumGeoreference
. When you first run in Play mode, the test scene will load in. After pressing "1", the scene will unload. The credits UI should not disappear.I even got this to work when the additive scene contained a tileset! In the first Cesium for Unity Sample scene, I moved Cesium OSM Buildings to a new georeference (same coordinates) under TestScene. Loading / unloading the scene properly updates the credit system in the original scene, without removing the UI. You can enable "Show Credits On Screen" to confirm that the original credit system updates for the tileset in the additive scene.
One problem here is, this all assumes the original credit system will not be unloaded. It's possible (though I don't know how practical) that the original scene is unloaded while additive ones remain. I tried fixing this but can't get it to work quite yet, so I'll write an issue and naybe address it in a follow-up PR.