CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
347 stars 83 forks source link

Use AssetDatabase.LoadAssetAtPath instead of Resources.Load in Editor #387

Closed kring closed 9 months ago

kring commented 9 months ago

After releasing Cesium for Unity v1.7.0, I did a final test with a clean Cesium for Unity Samples project, and found no Cesium ion assets could load because the project default token was blank. And in fact, Unity had modified the ion.cesium.com.asset file to remove the token. If I set the token again, it would be remembered. But this seemed to happen via modification to non-committed files in the Library directory, so I couldn't make the Samples project work out of the box. 🤕

Though I can't completely explain it, the problem appeared to be that Resources.Load<CesiumIonServer>("CesiumIonServers/ion.cesium.com") was returning null the first time, even though the asset file existed on disk. CesiumRuntimeSettings uses an alternate method to load an asset in the Editor (AssetDatabase.LoadAssetAtPath), and I guess I just learned why. After making CesiumIonServer do the same, the problem goes away. So that's what this PR does, and here comes v1.7.1.