hello,i have copy CesiumDefaultTilesetShader and add some parameters int it,but when i modify those parameters at runtime ,It doesn’t work。Only effective when I restart。
Right, because each tile gets its own instantiated copy of the material you select. If you need to modify material parameters are runtime, you need to loop through all of the tiles (they’re children of the Tileset) and modify the material on each.
how to loop through all of the tiles,i can’t find api to get all of the tiles
There isn’t a formal API for this, so you’d have to get all of the children of the tileset like any other game object. In Cesium for Unity, tiles are loaded like so:
Tileset Game Object
---- > Tile Game Object
--------------> Game Object with mesh
So you’d have to find all of the meshes in the tileset’s grandchildren and change their materials.
You should be able to get all of the MeshRenderer instances (one per tile) by calling tileset.GetComponentsInChildren<MeshRenderer>()
. Then access the material
property of each.
ok,i do it,it’s work
is there a way to know when Cesium is updating the tileset, so I know when to do this loop through the MeshRenderer? I don’t want to search for them every frame, just when there is a change.
There’s currently no event for an LOD switch, so you’ll have to poll for changes.