OrTools in Unity3D

508 views
Skip to first unread message

Olivier

unread,
Jan 24, 2018, 8:07:15 AM1/24/18
to or-tools-discuss
Hi !

I would love to use OrTools in Unity3D, especially the Minimum Cost Flow Algorithm.

I know it's more an Unity3D question than an OrTools question, but as Unity3D is very popular, it may still be of some interest. I asked on Unity's forums as well, but it seems the question doesn't draw much attention there.

Seeing that OrTools binaries are distributed for C#, I thought it would be easy to use OrTools in Unity3D. Unfortunately, I couldn't make it work so far.

I downloaded the binaries, and dropped Google.OrTools.dll and Google.Protobuf.dll to my Assets. In Visual Studio, when I add the DLLs using "Add reference", they seem to load correctly (I have auto completion). So I wrote some code. But back in Unity, I get compile errors (the faulty line is "Using Google.OrTools;") :


Assets/GameManagement/GameManager.cs(7,7): error CS0246: The type or namespace name `Google' could not be found. Are you missing an assembly reference?


I tried activating the experimental 4.6 .NET framework in the Player menu. It makes a difference, as it seems this time Google.Protobuf.dll is recognized, as now I get this error :


Assets/GameManagement/GameManager.cs(7,14): error CS0234: The type or namespace name `OrTools' does not exist in the namespace `Google'. Are you missing an assembly reference?


So it seems Google.Protobuf.dll is correctly loaded by Units3D, while OrTools.dll is not. Actually, in the Assets properties, I can see that Google.Protobuf.dll loads as a "managed" plugin, while Google.OrTools.dll loads as a "native" plugin.


After reading a little bit, I think I understood that there are "mixed assembly" (native and managed) DLLs, and I think Google.OrTools.dll is such a DLL. Is there a way to get the DLL working as a regular managed DLL ?


Or any other idea about how I can make this work ?



Thank you very much !!


Olivier

Laurent Perron

unread,
Jan 24, 2018, 11:03:44 AM1/24/18
to or-tools-discuss
No, most of the code is in C++.

And we only deliver the DLL compiled for intel 64 bit.

Still, it should be possible to compile for 32 bit is this is the blocking part.

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Olivier Dalang

unread,
Jan 24, 2018, 6:59:05 PM1/24/18
to or-tools...@googlegroups.com
Hi,

Thanks for your answer.

I'm not sure the problem is 32 vs 64 bits (new versions of Unity3D are 64 bits).

You say most of the code is C++, but still, in Visual Studio, I have autocomplete for classes/functions in C#, which means the .DLL includes some sort of C# bindings (also this is clearly supported as all examples include python/c# examples).

I think it's really a matter on how to get the DLL loading as Managed in Unity3D, but I'm not sure on how to do that. Is it possible to compile the DLL as a managed DLL somehow ?

Thanks,

Olivier







--
You received this message because you are subscribed to a topic in the Google Groups "or-tools-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/or-tools-discuss/pUkYG9pTxy4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to or-tools-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages