Jump to content
OpenSplice DDS Forum
alyshehata

Using Unity3d with OpenSplice

Recommended Posts

Hi. I've been able to use OpenSplice successfully to communicate between a Microsoft Kinect and a subscriber app. However, I would like to move this subscriber app from a standalone app, to Unity3d. This involves adding the .dll references. However, Unity3d uses Mono .Net 3.5 (which VS recognizes as .Net 2.0) which seems to be incompatible with OpenSplice. Is there any way to resolve that problem? 

 

The error messages I'm getting when building the project is as follows

Warning	1	The primary reference "ddsapihelper" could not be resolved because it was built against the ".NETFramework,Version=v4.0" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v3.5".	Assembly-CSharp-vs

Warning	2	The primary reference "ddsapihelper" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.	Assembly-CSharp-vs

Error	3	Metadata file 'f:\Unity\Demos\DestroyedCity\Assets\Plugins\dcpssacsAssembly.dll' could not be opened -- 'Error importing module 'dcpssacs.netmodule' of assembly 'f:\\Unity\Demos\DestroyedCity\Assets\Plugins\dcpssacsAssembly.dll' -- The system cannot find the file specified. '	F:\\Unity\Demos\DestroyedCity\CSC	Assembly-CSharp-vs

Share this post


Link to post
Share on other sites

I went down this path for about a day, and determined it would be a time sink of unknown duration.

Ended up using websockets to interface into unity.  There are several .net/mono websocket client libraries available.

 

To go from DDS to websockets, I use a 'homegrown' piece of bridge software, but the prismtech mobile stuff does this with ease.  Not sure if there is a free version, but PrismTech is very quick to give out demo licenses to help develop the first product.

 

An additional value of going to websockets is you then are using http, which can be a lot easier to pass around on the open internet or through company firewalls.

 

I know this is not helpful, "I couldn't figure it out either, so I did something else", but it did work in the end

 

regards,

Bud Davis

Share this post


Link to post
Share on other sites

I've found that Unity 4.6.3f1 (32bit) and 5.3.5f1 (64 bit) both seem to work fine with OpenSplice 6.4.140407OSS, at least in the Unity Editor. I've taken the code created by idlpp and brought it right into my projects. I'm publishing data from one project and subscribing to it from another. I'm using the stock dcpssacsAssembly.dll and I don't get any of the Framework errors reported by the OP. The problem I'm having is that when I try to run a build my OpenSplice based script fails to load with :

A script behaviour has a different serialization layout when loading. (Read 32 bytes but expected 308 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

My code doesn't use UNITY_EDITOR anywhere and the unfortunately the log doesn't really give me much else to go on. Everything works so well in the Editor that I'm really hoping there might be a straightforward fix for this.

Share this post


Link to post
Share on other sites

It turns out it was because Unity doesn't seem to automatically copy .netmodule files into builds. I did a manual build step to copy dcpssacs.netmodule and now its working fine.

Share this post


Link to post
Share on other sites

 

 

 

 

Ended up solving my issue, it had to do with using a sequence of floats.  I have no idea why but changing it to an array in the .idl file seemed to fix everything. 

Share this post


Link to post
Share on other sites

Happy to report that OpenSplice 6.7.170523 works with Unity 2017.1.0p4; just needed to go into Player settings and set "Scripting Runtime Version" to "Experimental (.NET 4.6 Equivalent)".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×