Hello,
i am trying to compile some NetworkBehaviour scripts into a DLL to be used inside a unity 2023.2.8f1 project. I’m using Visual Studio 2022 Managed Library project Net standard 2.1.
My script contains [ServerRcp] and [ClientRpc] but once i compile it, the dll is not working as expected.
I’ve inspected my script in my dll with IlSpy and it is clearly different compared to the same script compiled in Assemply-CSharp by Unity.
I understand that i’m missing something but i don’t know what, please can any one tell me how to correctly compile the dll?
I am creating a package to be used in unity editor and avoid any code inspection/modification. I know it’s a very basic protection but it is enough for what i have to do.
So please how can i include the code in my Visual Studio project?
Simply copying all com.unity.netcode.gameobjects folder or is there ia specific way?
Hopefully you’re not trying to do that for a store asset.
Putting code in a DLL that should be available as source deters potential customers. Developers with at least some experience avoid black boxes of other people’s code.
And as you said, the protection isn’t even there. With Rider I can inspect your DLLs C# code with a single click, and that code almost looks like someone disciplined wrote it, it’s not obscured with random names or such unless the DLL was explicitly obfuscated.
Thinking about this, Netcode depends on other packages, like Collections, and these again may depend on more. Even if that worked, you will end up including a lot of package code within the DLL. This means all the types and namespaces are duplicated in your DLL and then you get duplicate definition errors when you add that DLL to a Unity project.
I did a quick search for how a DLL can depend on a Unity Package Manager package but found nothing obvious. If at all possible, that’s the concept you need to research into.
The problem is that the package code itself is not meant to be compiled outside of a Unity project. And the way you got this DLL means the compiled package code would still contain duplicate definitions when added to a Unity project. On top, such a package DLL would be locked to the specific platform you built it for, and thus likely wouldn’t work for mobile or web or Mac, just Windows if that was the build target.