-
Notifications
You must be signed in to change notification settings - Fork 83
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
Inconsistancy In access modifiers in CesiumTileExcluder #527
Comments
@Reag can you elaborate on why you can't just enable / disable the MonoBehaviour? That's the intended way to turn the excluder on and off. AddToTileset / RemoveFromTileset definitely should not be called directly. For one thing, if you were to call RemoveFromTileset, and then refresh the tileset itself, the raster overlay would reappear. Disabling the component avoids that issue.
Yes, generally all Cesium objects need to be on or below the game object with the CesiumGeoreference. |
The main issue stems from the network architecture of our product. While the server is aware of all the cesium tilesets that could be loaded (One customer has over 200 in the system), the user clients only create the tilesets when the map moves into their bounding box. This means that as the users are manipulating the map, various tilesets can be added or removed via a networkmanager on the top level of the scene. Finally, the CesiumTileExcluder implementation we built has some moderately complex calculations involved every frame (involving the maps state, dimensions, and if the user has enabled particular functionalities), so we opted to have a single instance of the class manage all our tilesets. If we where to go with the monobehaviour enable/disable approach, I would have to disable then re-enable the monobehaviour every time this list updates. While definitely a technically valid solution, its also 'cursed'. Add to that the OnEnable and OnDisable involves a 'GetComponentInChildren' call at the top of a large hierarchy, I opted to manage the tileset states manually via an override. |
I still don't quite follow what's cursed about it.
Have you measured this to take a significant amount of time? Compared to the work that Cesium for Unity needs to do when a raster overlay is added or removed, I'd be really surprised if this is significant. |
Minor issue I noticed while implementing a custom CesiumTileExcluder implementation:
OnEnable() and OnDisable() are marked as 'protected virtual', which implies that developers are invited to override these methods with their own custom implementations. However, the only way to actually access the functionality of the CesiumTileExcluder is via the AddToTileset and RemoveFromTileset internal methods. Thus only if you are in the Cesium namespace these methods are accessible. Thus if you don't want to call the default OnEnable or OnDisable behaviors, the component cannot have functionality.
In my particular case, I wish to Add and Remove the excluder from the tileset under very specific circumstances. This leaves me with a choice of doing some very 'cursed' monobehaviour enable/disable manipulation or building a special asmdef extension. My actual solution ended up looking like this, with the class being inside the cesium namespace:
[EDIT]: I just noticed, but the description of the CesiumTileExcluder seems to imply that you can place it anywhere in the hierarchy above a tileset for it to work, but it will only work if its below or on the GeoReference. Is this intended? If so, it might be a good idea to give a small update to the description.
The text was updated successfully, but these errors were encountered: