FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: cache HasAuthority to avoid recomputing it on every access by noellie-velez · Pull Request #4026 · Unity-Technologies/com.unity.netcode.gameobjects · GitHub

chore: cache HasAuthority to avoid recomputing it on every access - #4026

Merged
noellie-velez merged 16 commits into
develop-2.0.0from
refactor/use-internal-has-authority-network-object
Jun 30, 2026
Merged

chore: cache HasAuthority to avoid recomputing it on every access#4026
noellie-velez merged 16 commits into
develop-2.0.0from
refactor/use-internal-has-authority-network-object

Conversation

noellie-velez commented Jun 11, 2026
edited
Loading

Copy link
Copy Markdown
Collaborator

Purpose of this PR

  • refactor: precalculate HasAuthority into cached m_HasAuthority field
    • Removed InternalHasAuthority() and replaced with private m_HasAuthority field
    • Set m_HasAuthority on Spawn (before SpawnInternal), cleared on despawn, updated on ownership change
    • Replaced all internal HasAuthority call sites with direct m_HasAuthority field access
    • Updated public HasAuthority property to return cached value when spawned
    • Moved network object setup from NetworkSpawnManager.SpawnNetworkObjectLocallyCommon to NetworkObject.SetupOnSpawn

Jira ticket

MTT-14792

Changelog

N/A

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Backports

N/A

noellie-velez changed the title refactor: use InternalHasAuthority() for all internal authority checks in NetworkObject refactor: use InternalHasAuthority() for internal self-calls in NetworkObject Jun 11, 2026
Update it on Spawn, InvokeBehaviourOnOwnershipChanged and ResetOnDespawn
noellie-velez changed the title refactor: use InternalHasAuthority() for internal self-calls in NetworkObject refactor: cache HasAuthority to avoid recomputing it on every access Jun 15, 2026
noellie-velez marked this pull request as ready for review June 15, 2026 16:51
noellie-velez requested a review from a team as a code owner June 15, 2026 16:51
noellie-velez changed the title refactor: cache HasAuthority to avoid recomputing it on every access chore: cache HasAuthority to avoid recomputing it on every access Jun 16, 2026
noellie-velez requested a review from EmandM June 17, 2026 17:41
noellie-velez enabled auto-merge (squash) June 29, 2026 14:36
noellie-velez merged commit e6ecb65 into develop-2.0.0 Jun 30, 2026
23 of 25 checks passed
noellie-velez deleted the refactor/use-internal-has-authority-network-object branch June 30, 2026 21:36
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL