UNetWeaver error + Failure generating network code
After upgrading to Unity 5.2.2 from 5.0.1, two errors have appeared in the console. They are as follows:
UNetWeaver error: Exception :Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'UnityEngine.Networking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
at Mono.Cecil.DefaultAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0
at Mono.Cecil.TypeReference.Resolve () [0x00000] in <filename unknown>:0
at Unity.UNetWeaver.Weaver.ResolveMethod (Mono.Cecil.TypeReference t, System.String name) [0x0001e] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1013
at Unity.UNetWeaver.Weaver.SetupTargetTypes () [0x00776] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1279
at Unity.UNetWeaver.Weaver.Weave (System.String assName, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x0003e] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1570
at Unity.UNetWeaver.Weaver.WeaveAssemblies (IEnumerable`1 assemblies, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String outputDir, System.String unityEngineDLLPath, System.String unityUNetDLLPath) [0x00062] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1676
UnityEngine.Debug:LogError(Object)
Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:20)
Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, IAssemblyResolver, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1683)
Unity.UNetWeaver.Program:process(String, String, String, String[], String[], IAssemblyResolver, Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:34)
UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)
and
Failure generating network code.
UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)
I have done some research into these errors here and here and they seem to be either a Unity bug (which was supposedly fixed in 5.1) or a problem with a Unity Standard Asset. The error doesn't seem to be too common which is surprising since for me, it is caused when I import the Unity Standard Asset: FOVKick.cs in the Utility folder. I found a forum here with a similar error saying something about using command lines. These command lines are present in the FOVKick script below:
using System;
using System.Collections;
using UnityEngine;
namespace UnityStandardAssets.Utility
{
[Serializable]
public class FOVKick
{
public Camera Camera; // optional camera setup, if null the main camera will be used
[HideInInspector] public float originalFov; // the original fov
public float FOVIncrease = 3f; // the amount the field of view increases when going into a run
public float TimeToIncrease = 1f; // the amount of time the field of view will increase over
public float TimeToDecrease = 1f; // the amount of time the field of view will take to return to its original size
public AnimationCurve IncreaseCurve;
public void Setup(Camera camera)
{
CheckStatus(camera);
Camera = camera;
originalFov = camera.fieldOfView;
}
private void CheckStatus(Camera camera)
{
if (camera == null)
{
throw new Exception("FOVKick camera is null, please supply the camera to the constructor");
}
if (IncreaseCurve == null)
{
throw new Exception(
"FOVKick Increase curve is null, please define the curve for the field of view kicks");
}
}
public void ChangeCamera(Camera camera)
{
Camera = camera;
}
public IEnumerator FOVKickUp()
{
float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease);
while (t < TimeToIncrease)
{
Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToIncrease)*FOVIncrease);
t += Time.deltaTime;
yield return new WaitForEndOfFrame();
}
}
public IEnumerator FOVKickDown()
{
float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease);
while (t > 0)
{
Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToDecrease)*FOVIncrease);
t -= Time.deltaTime;
yield return new WaitForEndOfFrame();
}
//make sure that fov returns to the original size
Camera.fieldOfView = originalFov;
}
}
}
I hope you can help, I'm not sure why this is happening but at least I've found a lot of information about it. Is there any way to fix it except for downgrading? It's stopping my project!
I do not use networking and do not want multiplayer in my project but it gives me this error just because of one asset.
Your answer
![](https://koobas.hobune.stream/wayback/20220612045747im_/https://answers.unity.com/themes/thub/images/avi.jpg)