Closed etiennepinchon closed 5 years ago
I'll have a go at adding a project to Unity today and let you know if I get it working. It's been a while since I used Unity with Networker but need to make sure it's still OK!
I got it working for .NET 4.* but not for standard 2.0, there's some horrible reference conflicts going on
Change your Unity project to target .NET 4.*
• Create a new C# project which references Networker and targets .NET 4.7.2 • Set to Release • Build • Go to output and copy the .DLL files, put them into a folder in your Unity project called Plugins • Create new script for your network code in unity project which derives from MonoBehavior
That worked! Thank you very much @MarkioE
Additionally I found a way to bundle all the dlls together to makes things a bit cleaner in Unity using ILRepacker by adding the following code in the vs project:
<ItemGroup>
<InputAssemblies Include="$(TargetPath)" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.DependencyInjection'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.DependencyInjection.Abstractions'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Logging'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Logging.Abstractions'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Logging.Configuration'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Configuration'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Configuration.Abstractions'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Options.ConfigurationExtensions'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Options'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Logging'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Primitives'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.Extensions.Configuration.Binder'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'System.Memory'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'System.Runtime.Extensions'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'System.Buffers'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'System.ComponentModel.Annotations'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'System.Numerics.Vectors'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'System.Runtime'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'System.Runtime.CompilerServices.Unsafe'" />
</ItemGroup>
<ILRepack AllowDuplicateResources="false" DebugInfo="true" Internalize="true" InputAssemblies="@(InputAssemblies)" OutputFile="$(TargetPath)" Parallel="true" TargetKind="SameAsPrimaryAssembly" />
</Target> ```
Hi,
I spent the whole day trying to make this project work with Unity but unfortunately I still cannot import the dll without errors. I tried many different things and it seems like the necessary dependencies are not included in the build. Here is the kind of errors I am getting when importing the dll of Networker:
Any idea what I am doing wrong or how to fix it?
Thank you, Etienne