- Home /
UNET lazy loading, what does it mean?
I have a situation where I am registering NetworkIdentity Prefabs with the NetworkManager in code. When spawning those on the client I receive the following message followed by a list of CRC mismatches, listing every script on that prefab with a count of 0:
Network configuration mismatch detected. The number of networked scripts on the client does not match the number of networked scripts on the server. This could be caused by lazy loading of scripts on the client. This warning can be disabled by the checkbox in NetworkManager Script CRC Check.
What does lazy loading mean? The code works, but it feels wrong and from the looks of the CRCcheck option in the NetworkManager I actually only would want to use it if I was dealing with completely different projects networking with one another.
How do I get rid of this? Is there something wrong with the code?
Answer by Baxter900 · May 08, 2018 at 06:18 PM
"Lazy Loading" is a term for loading something only as it's needed (as opposed to loading everything upfront).
All the warning is telling you is that that at some point, you have a different amount of network scripts on the client ant the server, if you're registering the NetworkIdentity Prefabs in code after a connection is made, this is to be expected. If you wish to continue lazy loading, the checkbox is fine. The reason why the warning is there in the first place is that lazy loading like you are can cause problems if you don't ensure that both the server and all clients have registered a prefab before spawning it. I'd personally advise registering all necessary prefabs before the connection is made in the first place. This will satisfy the check, and means you'll get a warning if there's ever a mismatch across server and client (the same message you're getting now).
awesome answer, thanks, but one more on the topic. today I found out that using OnStartClient in a gameobject in the online scene (Network$$anonymous$$anager) is too late for the lazy registration when running server and client on the same machine. All that was left is Awake, and only Awake. Would you know if that's correct or where connections even CAN be registered?
Your answer
Follow this Question
Related Questions
Spawn Prefab inside another Prefab 0 Answers
Player Prefab on Lobby Managers? 5 Answers
UNet Parent System 0 Answers
Unity Networking: Object only spawning on the Host client. 2 Answers