Is there a way to link against UnityEngine.dll from a standalone Win32 or .Net application, like I used to do with DirectX ? I dug and drilled down the all possible WEB reference including this answers database. All I could find is this: Is it possible to build a standalone .net application that link UnityEngine.dll and this: Is it possible to start Unity from a C# project ? links, with negative answers more than 10 years ago, so maybe since then there is some other positive option for my question ? . I also checked this nice GitHube example: Unity-Technologies NativeRenderingPlugin but again it was something else, that doesn’t answer my question .
No, that’s not possible. Unity is not a .NET application at all. The Unity engine is mainly written in C++. Unity just uses Mono / .NET as a scripting layer. With IL2CPP even your .NET code is cross compiled to C++. The UnityEngine.dll is just a managed wrapper for the native code. There is almost no functionality inside the UnityEngine dll. The source code of the UnityEngine dll is actually on Github. However it is released for reference only and you are not allowed to use / copy any of the code. They just put it up there since everyone can just use a .NET reflector to reconstruct the source code. However the original source code also includes comments and local variables still have a meaningful name.
It wouldn’t even help much to use the DLL since most of the important / heavy code is on the native C++ side. For example this is the Quaternion struct, but only the managed part. Besides the basic stuff there are also those “external” defined methods. The Transform component consists almost exclusively of external properties / methods. There is no data stored on the .NET / managed side in those classes.
AFAIK in the past the engine core was directly compiled into the Unity player “.exe” that is shipped with your build. It looks like they actually seperated most of it into the UnityPlayer.dll. Just as a side note: Even if it would be possible to somehow initialize and use the Unity engine inside of your .NET application, the license does not allow any usage outside a Unity project. See the EULA and Terms of services
.1.1 Use Rights.
[ … ] Unity grants you a
royalty-free right: [ … ] to
distribute the runtime portion of the
Unity Software intended for
distribution as an integrated part of
your Project Content (the “Unity
Runtime”), solely as embedded or
incorporated into your Project
Note that I’m not a lawyer. If you have any questions regarding licencing terms, please contact Unity Technologies or ask a lawyer.
There are ways to integrage a Unity build (or any other application for that matter) into another application. On windows you can use the usual WinAPI stuff to change the parent of a window. However you should be really careful how you do that. Depending on your license you might not be allowed to load Unity in the background which might hide the splash screen from the enduser. There are many potential legal pitfalls.
You can use VS with unity just fine its just that on build unity overwrites the solution file making using the default solution a no no if you are trying to organise your code with additional projects.
All you need to do is create a new solution referencing the right Unity assemblies either locally or by grabbing them in as a nuget package (but not including your default unity project). Then you just need to set the build output of your class library projects in your new solution to the right location in the unity project and it should work fine without running the risk of being overwritten on build.
i.e. just treat your game code as an external dependency and load it into unity that way.