Skip to content

Conversation

@noellie-velez
Copy link
Collaborator

@noellie-velez noellie-velez commented Dec 29, 2025

Purpose of this PR

Jira ticket

MTT-13657

Changelog

  • Changed: optimize NetworkManager accessors
  • Changed: styling (fixing typos and minor styling)
  • Changed: use explicit Unity engine object lifetime check

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


// Standard non-authority synchronization is handled here
if (!CanCommitToTransform && NetworkManager.IsConnectedClient && SynchronizeState.IsSynchronizing)
if (!CanCommitToTransform && m_CachedNetworkManager.IsConnectedClient && SynchronizeState.IsSynchronizing)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change useful on an optimization point of view?

var forUpdate = true;
#endif
if (m_CachedNetworkObject != null)
if (m_CachedNetworkObject)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rider suggested converting "==" to explicit Unity engine object lifetime check. Should we keep or revert those changes?

return GlobalObjectIdHash;
}
}
public uint PrefabIdHash => GlobalObjectIdHash;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep this in multiple lines instead of my change?

// the NetworkManager is shutting down, the NetworkObject is not spawned, it is an in-scene placed
// NetworkObject, or the GameObject's current scene handle is the same as the SceneOriginHandle
if (!SceneMigrationSynchronization || !IsSpawned || NetworkManager == null || NetworkManager.ShutdownInProgress ||
if (!SceneMigrationSynchronization || !IsSpawned || NetworkManager.ShutdownInProgress ||
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep NetworkManager null checks here?

// Early exit if there is no NetworkManager assigned, the NetworkManager is shutting down, the NetworkObject
// is not spawned, or an in-scene placed NetworkObject
if (NetworkManager == null || NetworkManager.ShutdownInProgress || !IsSpawned || IsSceneObject != false)
if (NetworkManager.ShutdownInProgress || !IsSpawned || IsSceneObject != false)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the NetworkManager null checks here?

/// Gets if the object is the personal clients player object
/// </summary>
public bool IsLocalPlayer => NetworkManager != null && IsPlayerObject && OwnerClientId == NetworkManager.LocalClientId;
public bool IsLocalPlayer => IsPlayerObject && OwnerClientId == NetworkManager.LocalClientId;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, NetworkManager cannot be null as we are using the Singleton so I removed some NetworkManager null checks. Should those checks be kept anyways?

@noellie-velez noellie-velez marked this pull request as ready for review December 30, 2025 14:54
@noellie-velez noellie-velez requested a review from a team as a code owner December 30, 2025 14:54
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.

2 participants