error Netcode: System.InvalidOperationException: Cannot find Unity.NetCode metadata reference for assembly BovineLabs.Saving
at Unity.NetCode.Generators.TemplateParser.ParseTemplatesFromMetadata(GeneratorExecutionContext context, IList`1 templates)
at Unity.NetCode.Generators.TemplateParser.ParseTemplates(GeneratorExecutionContext context)
at Unity.NetCode.Generators.NetCodeSourceGenerator.Generate(GeneratorExecutionContext executionContext, Candidates candidates, IDiagnosticReporter diagnostic)
at Unity.NetCode.Generators.NetCodeSourceGenerator.Execute(GeneratorExecutionContext executionContext)
Iâm having an immediate issue after updating to 0.51 where if I have an assembly that does not use netcode is referenced by an assembly that does use netcode I just get the above locking error. Itâs fixable by making the assembly reference Netcode.
e.g.
GameAssembly
References Netcode
References Saving
SavingAssembly
References nothing
Above error
Adding Netcode to SavingAssembly fixes error.
This happens in a brand new project just adding in in 2 existing libraries.
-edit- actually I think it might be reversed
Core references Netcode
Saving references Core
Even if saving does not use any Netcode it needs a reference on Netcode otherwise errors
What editor version are you using?
We fixed that problem recently and Iâm honestly quite surprised you have that issue. Since there are tons of assemblies that does not used NetCode that are processed without problems.
The assemblies only contains one file, with one component each.
The assembly that has netcode references also replicate that component (he has ghost fields)
Also, given the error you get I suspect the problem is elsewhere. In particular, the compilation pipeline is passing/running (erroneously) the NetCodeSourceGenerator to assemblies that does not reference netcode. That is wrong, it is not the expected behaviour. This is why that method trigger an exception.
We can fix in netcode package by adding some extra checks and skip the problem altogether. But I would like to be able to repro the problem myself first.
I might suspect that is an issue due to the upgrade / update. If I start from scratch a project I might not be able to see any issue there.
Can you please check that if you now, after you updated everything, remove all the netcode reference, delete the library folder and re-import the project, everything works?
Actually I got the error in a a brand new empty project copying in libraries in. When upgrading my project I was just getting a generic errors that didnât help at all and wouldnât compile (even though I deleted entire library before upgrading).
Luckily my project is extremely modular so instead I created a fresh project and slowly brought libraries into it until I got errors. Once I fixed these up and copied back changes to original project it compiled fine.
When I get off from work Iâll try remove the references I added and see if it still fails.
I can probably rollback to my pre-upgrade state, test if I can repo the same thing in an empty project and if so just send you a library that fails.
Can you guys please report this issue using the UnityEditor bug report ? So we can keep track of it.
I was unable so far to repro the problem, but Iâm probably doing something different you are. Would be great if you can provide a project (hopeufully a test project) where the problem occurs.
In order to give you the hot-fix I need to re-compile the netcode-generator and push some dlls in the forum.
That is usually not what I would like to do, I would prefer to release a proper package fix instead (seem more legit).
Let me see what the ETA for a package update would first.
Hi Phil,
Can you please share the project (or a similar setup) where the problem occur?
I tried doing the same in a new project or even in older ones but Iâm not able to repro it, even though I have a similar setup.
Question for you: when you got this problem, there was some script error or api update or your were in safe-mode?
So, since there are already 3/4 persons that are getting this issue I decided to publish an hot-fix here (even though is not the best but lets try).
Attached youâd find the new compiled version of the source generator that should fix that issue.
Please (if you didnât already) move the com.unity.netcode from the Library/PackageCache into your package folder (or another directory and then set the manifest accordingly) and unzip the dlls into the com.unity.netcode/Runtime/Gen folder (where they currently are)
Could you also please let me know if that fix your problems?
After applying the hotfix, Iâm getting this error:
First line says âCannot load template âŚ/GhostComponentSerializer.csâ and âPackage com.unity.netcode not foundâ, but GhostComponentSerializer.cs does exist at the specified path, and my custom netcode package is detected by the package manager
EDIT: actually, I get this same error even when I just copy the netcode folder into my Packages folder and remove netcode from my package manifest, without applying the hotfix. I might be doing something wrong?
I also havenât been able to repro in a new project, even when starting out in 2020.3 and then upgrating to 2021.3
ohh, that is not what I was expecting to see, I apologies, I tried my self the same fix but I didnât get that error. I will by moving netcode in the package folder and fix the problem.
Not sure if this is the issue you are seeing, but there is one big pitfall with doing this - when you copy the folder into the package folder you must rename it so the path is Packages/com.unity.netcode/ - if you just move it and keep the @0.51.0-preview in the folder path it will not work.
I see, Iâve tried it again and now I can confirm the fix works. I was able to remove the NetCode reference from some of my assemblies and the errors donât appear anymore. Thanks!
I wonât be able to use the hotfix for my project specifically, because itâs an asset store project. But Iâd be interested in knowing if there are plans to release an official package update containing the fix in the near future?
Hi @CMarastoni . Iâm getting these messages with or without an assembly definition while following Networked Cube | Netcode for Entities | 1.0.17 as soon as I create the âGame.csâ script under the âEstablishing a connectionâ section. The above steps donât seem to do anything (which isnât a surprise given thereâs no com.unity.netcode/Runtime/Gen folder in the latest version).
On a hunch, I also tried deleting the existing âNetCodeSourceGenerator.dllâ and renaming the Hotfix file âUnity.NetCode.SourceGenerators.dllâ to match, but that didnât make a difference.
In both cases, Unity boots into safe mode and gives me variations on:
Packages\com.unity.netcode\Runtime\Physics\PhysicsVelocityVariant.cs(32,34): error CS0433: The type âGhostPrefabTypeâ exists in both âGeneratorShared, Version=0.0.0.0, Culture=neutral, PublicKeyToken=nullâ and âUnity.NetCode, Version=0.0.0.0, Culture=neutral, PublicKeyToken=nullâ