镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Unity serialization exception from NetworkConnection constructor after upgrading to Mirror 96.11.3 #4130

Open

Description

@lcompton

Description

After upgrading Mirror from 96.11.2 to 96.11.3, I began getting repeated Unity serialization exceptions involving NetworkConnection.

Downgrading to Mirror 96.11.2 eliminates the exceptions without any other code changes.

Environment

  • Unity: 6000.6.3f1
  • Mirror: 96.11.3
  • Last known working Mirror version: 96.11.2

Exception

UnityException: get_time is not allowed to be called during serialization, call it from Awake or Start instead. Called from MonoBehaviour 'NetworkIdentity' on game object 'Player'.
See "Script Serialization" page in the Unity Manual for further details.
Mirror.NetworkConnection..ctor () (at Assets/Mirror/Core/NetworkConnection.cs:65)
Mirror.NetworkConnectionToClient..ctor () (at Assets/Mirror/Core/NetworkConnectionToClient.cs:63)
UnityEngine.StackTraceUtility:ExtractStringFromExceptionInternal(Object, String&, String&)

Network prefab registration

One potentially relevant detail is that I do not maintain the network prefab list manually in the NetworkManager inspector.

My network prefabs are loaded as Addressables and registered programmatically using:

NetworkClient.RegisterPrefab(networkIdentity.gameObject);

This worked without the serialization exceptions under Mirror 96.11.2.

Reproduction / regression

I believe the following steps will reproduce the issue, although I haven't verified...

  1. Create a project using Unity 6000.6.3f1.
  2. Install Mirror 96.11.3.
  3. Create a prefab with a NetworkIdentity.
  4. Create a script that registers the prefab with NetworkClient.RegisterPrefab().
  5. get_time is not allowed to be called during serialization exception occurs.

Activity

  1. lcompton commented on Sep 28, 2026

    @lcompton
    Author

    One thing I neglected to mention is that the network prefab registration occurs in the process of warming a cache of ScriptableObjects loaded via the Addressables system. Here are the relevant C# files...
    ConfigDefinition.cs
    ConfigRegistry.cs

  2. MrGadget1024 commented on Sep 28, 2026

    @MrGadget1024
    Collaborator

    Which change in this commit do you think is the breaking change? Either add them individually from 11.2 or remove them from 11.3.

  3. lcompton commented on Sep 29, 2026

    @lcompton
    Author

    Adding "[Serializable]" to NetworkConnection and NetworkConnectionToClient in 96.11.2 caused the exceptions to appear. I stopped there.

  4. MrGadget1024 commented on Sep 30, 2026

    @MrGadget1024
    Collaborator

    Adding "[Serializable]" to NetworkConnection and NetworkConnectionToClient in 96.11.2 caused the exceptions to appear. I stopped there.

    Try 11.3 and change those to [System.NonSerialized] instead and see if that works.

  5. lcompton commented on Oct 1, 2026

    @lcompton
    Author

    "[NonSerialized]" can only be applied to fields. I tried putting "[NonSerialized]" on "lastMessageTime". That did not solve the problem.

  6. MrGadget1024 commented on Oct 1, 2026

    @MrGadget1024
    Collaborator

    "[NonSerialized]" can only be applied to fields. I tried putting "[NonSerialized]" on "lastMessageTime". That did not solve the problem.

    Might just have to remove the attributes and live with the annoying warnings from Unity.

  7. lcompton commented on Oct 2, 2026

    @lcompton
    Author

    Perhaps there's an alternative to running Time.time in that constructor. Do those classes need to be Serializable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions