Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

[Unity x Mirror] Can not create because it had empty assetid

Discussion in 'Multiplayer' started by AnfrayL, Mar 22, 2021.

  1. AnfrayL


    Mar 25, 2020
    Hi Everyone !

    I hope you can help me on this one... I've been stuck for a week on this weird issue that happens about 1/5 of the times when I launch NetworkManager.singleton.StartHost() or StartClient().
    I haven't found a proper way to replicate it everytime, but when it happens, I will have to restart my build/editor until the message disappears.
    I run Unity 2020.2.7f1 with Mirror 32.1.4

    I've been working on this multiplayer scene that worked perfectly. This bug started when I developped a lobby to get rid of the NetworkManager GUI.

    The complete error message will be paste on the bottom of the message.
    Sorry for all the details, but since I cannot replicate this, I'm putting as much info as I can to not miss anything ^^

    The Network Manager that I use is a custom one that contains a Player Prefab and a Registered Spawnable Prefab :

    The code that I use that starts this problem is quite simple :
    Code (CSharp):
    2. //Called when "Join" button is pressed
    3. public void Join()
    4.     {
    5.         string address = inputField.text.text.ToLower(); //This is set as default as "localhost"
    6.         Debug.Log(;
    7.         NetworkManager.singleton.networkAddress = address; //Set the adress based on my custom inputField
    8.         NetworkManager.singleton.StartClient(); //Start as a Client
    9.         lobby.SetActive(true); //Activate lobby UI
    10.         stateMachine.changeActiveObject(StartButton.leftButton);
    11.     }
    13. //Called when "Host" button is pressed
    14.     public void Host()
    15.     {
    16.         lobby.SetActive(true); //Activate lobby UI
    17.         stateMachine.changeActiveObject(StartButton.leftButton);
    18.         NetworkManager.singleton.StartHost(); //Start as a Host
    19.         string address = inputField.text.text.ToLower();//This is set as default as "localhost"
    20.         NetworkManager.singleton.networkAddress = address;//Set the adress based on my custom inputField
    21.     }
    When my "can not register" error appears, it appears appear for every object registered as player or spawnable prefab.


    When I use another build (as client) to connect my client-server build that throws this error, my client build, throws these message

    "Can not Register 'NetworkPlayer' because it had empty assetid. If this is a scene Object use RegisterSpawnHandler instead
    UnityEngine.Logger:Log (UnityEngine.LogType,object)
    Mirror.ILoggerExtensions:LogError (UnityEngine.ILogger,object) (at Assets/Mirror/Runtime/Logging/LogFactory.cs:82)
    Mirror.ClientScene:RegisterPrefabIdentity (Mirror.NetworkIdentity) (at Assets/Mirror/Runtime/ClientScene.cs:252)
    Mirror.ClientScene:RegisterPrefab (UnityEngine.GameObject) (at Assets/Mirror/Runtime/ClientScene.cs:347)
    Mirror.NetworkManager:RegisterClientMessages () (at Assets/Mirror/Runtime/NetworkManager.cs:795)
    Mirror.NetworkManager:StartClient () (at Assets/Mirror/Runtime/NetworkManager.cs:430)
    OnlineLobbyScript:Join () (at Assets/OnlineLobbyScript.cs:64)
    UnityEngine.Events.UnityEvent`1<UnityEngine.EventSystems.BaseEventData>:Invoke (UnityEngine.EventSystems.BaseEventData)
    UIButton:ExecuteFunction () (at Assets/UIButton.cs:43)
    UIStateMachine:OnNotify (UnityEngine.GameObject,object) (at Assets/UIStateMachine.cs:68)
    Subject:Notify (object) (at Assets/_Game/_Script/Helpers/Variables/Subject.cs:61)
    InputHandler:OnSpecialAction (UnityEngine.InputSystem.InputValue) (at Assets/_Game/_Script/InputHandler.cs:61)
    UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
    UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)"

    Does anyone have an idea on how to fix this ?
    I thank you very much in advance because I am completely lost ^^'
  2. AnfrayL


    Mar 25, 2020
    I forgot to mention, both prefabs NetworkPlayer and OnlineMultiplayerPrefabTest are not empty, the root gameobject contains a NetworkIdentity as well as custom NetworkBehaviours.
    Edomerify likes this.
  3. Edomerify


    Nov 12, 2019
    Same issue here! Have you resolved your issue?
  4. AnfrayL


    Mar 25, 2020
    Unfortunately no. I couldn't find any fix and since there was no reply I abandoned Online Multiplayer for this project.
    If you ever find a solution, please post it, I'd be glad to read it !