Repository navigation
Add NetworkColliderBase GetLayers/SetLayers - #1093
Open
jimdroberts wants to merge 1 commit into
Open
jimdroberts wants to merge 1 commit into
jimdroberts wants to merge 1 commit into
Conversation
Layers is a protected field and the concrete NetworkTrigger/NetworkCollision components are sealed, so code could neither read nor set the query mask. Add GetLayers/SetLayers. SetLayers resets the cached GameObject layer so that going back to Nothing derives the mask from the collision matrix again. The Layers tooltip now documents that fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
NetworkTrigger,NetworkCollisionandNetworkTrigger2Daresealed, and theirLayersmask is aprotectedfield. There is no way to read or set the query layers from code. A component added withAddComponent, or one whose required layers are only known at runtime, is stuck with the serialized value.When the mask is wrong, nothing reports it. If
Layersis nothing, the mask is derived from the collision-matrix row of the component's own GameObject layer. IfLayersis authored without a needed bit, those objects are simply never overlapped. The tooltip only says "This is used when value is not nothing", so the fallback is not discoverable.Cause
Runtime/Generated/Component/Prediction/NetworkColliderBase.cson main:protected LayerMask Layershas no public accessor. The concrete components aresealed, so it cannot be reached by subclassing either.TryPrepareColliderCheckusesLayerswhen it is not nothing. Otherwise it usesLayers.GetInteractableLayersValue(gameObject.layer), cached by_lastGameObjectLayer.Fix
GetLayers()/SetLayers(LayerMask), following the Get/Set accessor style used elsewhere (for exampleNetworkTransform.SetSendToOwner).SetLayersresets_lastGameObjectLayer. Without that, switching from an explicit mask back to nothing would keep using the explicit mask:InteractableLayerswas overwritten, and the layer cache still matched the GameObject's layer. The new value takes effect on the next check.Layerssummary and tooltip now describe the fallback when the value is nothing.No warning is added for
Layers == 0. It is a documented, working default, and warning on it would flag every correctly configured project.