-
-
Notifications
You must be signed in to change notification settings - Fork 71
Unity3D Integration
QuikGraph is built under several targets to offer the maximum features for each of them.
As a consequence of its wide targeting, it is possible to use QuikGraph library under the famous Unity 3D game engine.
Here is a video that showcases how to integrate a library that comes from NuGet.org into a Unity project. The example is the one of NewtonSoft.Json but is also applicable to QuikGraph.
Here is a tiny Unity project that is already setup to use QuikGraph (2.3.0 .NET Standard 2.0)! Note that you can also use library that targets .NET Framework rather that .NET Standard.
The sample only consist in a QuikGraph dll put in Plugins folder and using it in a script to log edges from a graph constructed on the fly.
Assembly details:
Unity overview:
QuikGraph comes with features related to serialization in QuikGraph.Serialization
assembly.
Among those features there is one that is not always supported by Unity which is the GraphML serialization (other serialization methods work).
As for now all Unity versions <= 2020.3 are partially supporting it (feel free to ping QuikGraph owners to inform about changes related to this).
Unity 3D has a specific C# environment, this has some consequences and some stuff that normally works or is supported in standard C# application may not be usable under Unity.
It will mainly depend on the project setting relative to the C# scripting runtime (Edit > Project Settings > Player > Configuration > API Compatibility Level). By default Unity projects are setup to use the .NET Standard 2.0 compatibility level which in most cases will certainly fit and work.
The GraphML serialization is using some code generation at runtime through DynamicMethod API. This is an API that is quite old in the .NET Framework but not in .NET Standard. As a consequence this method of serialization will not work for projects that are setup to use .NET Standard 2.0 compatibility level.
However it is possible to use GraphML serialization but you will have to make changes in your project settings and make it using API compatibility level .NET 4.x (using QuikGraph libraries targeting .NET Framework should not be mandatory the .NET Standard 2.0 builds should be enough).
If this project setting change is not possible on your end, then you will not be able to fully use the QuikGraph.Serialization features. :-(
A quick check you can do to verify if Unity is supporting this kind of stuff is to try compile a C# script that is declaring a DynamicMethod
. If compilation is ok then you should be able to use the feature, otherwise not.