Support for Unity Game Engine

16 posts / 0 new
Last post
Offline
Last seen: 9 years 6 months ago
Joined: 09/10/2014
Posts: 1
Support for Unity Game Engine

Hello my learned friends.

We are looking at implementing a simulation environment and need to communicate with the Unity Game Engine. So far I have found two products that look like they come close from VT Mäk but I cannot say with any degree of confidence they are what we are looking for.

Does anyone know of a suitable (preferably RTI based) product that will interface with Unity? Have any of you gone through this process already?
All advice is appreciated.

Cheers.

Organization:
gianpiero's picture
Offline
Last seen: 2 months 1 week ago
Joined: 06/02/2010
Posts: 177

Hi there,

I am not an expert on unity but I think unity uses C# (among other languages) as main language development.. right? Could you use our c# api?

-- Gianpiero

Offline
Last seen: 1 month 2 weeks ago
Joined: 01/25/2017
Posts: 3

Unfortunately since even the latest version of Unity, 5.5, is still based on .NET 3.5 I don't think it will work with Connext. I tried copying the nddsdotnet DDL's into my project folder and when I click on them in the Inspector they are shown as native instead of managed and the "Assembly Info" field (which should show the .NET version) is not displayed. Unity has a mono update on their roadmap and there are some preview betas available on their forums but the update isn't targeted for 5.6 so my guess is that it might be quite some time before we see it in a production release.

I believe the specific flavor of the tool the original poster linked to was actually VR-Link for Unity. This connects Unity with the DIS & HLA military simulation protocols, the latter of which has a component called the RTI (run time infrastructure) which is sometimes confused with the company but unfortunately this tool does not support DDS.

Unity also supports Javascript so it may be possible to use Connext via the RTI Connector.

Offline
Last seen: 1 month 2 weeks ago
Joined: 01/25/2017
Posts: 3

Upon further investigation I think the problem is that the Connext .NET DLL's aren't pure CIL (i.e. they're a mixture of managed and unmanaged code). Mixed assemblies aren't supported by Mono so unfortunately at this point I don't think Connext is going to be compatible with Unity.

sara's picture
Offline
Last seen: 1 year 3 months ago
Joined: 01/16/2013
Posts: 128

Hi,

As Constellation mentioned, RTI Connext for C# is based on CLI/C++ and it is not 100% compatible with Mono. That said, we are working on gathering interest from customers to see if we can create a new version of our C# API that is completly compatible with Mono. This would help not only people using Unity, but people using C# on Linux.

If you are interested, please contact your account team with your account information and let them know. If you are in Europe, you can contact me (I'm FAE in EMEA) at sara(AT)rti.com.

Thanks,

Sara

sara's picture
Offline
Last seen: 1 year 3 months ago
Joined: 01/16/2013
Posts: 128

Hi everybody,

Quick update on this. We created a version of Connector that enables RTI Connext for Unity 3D engine. You can find it in our github repository: https://github.com/rticommunity/rticonnextdds-connector-cs

All the best,
Sara

Edit: Updated repo link

Offline
Last seen: 4 years 5 months ago
Joined: 10/01/2019
Posts: 5

Hello all,

RTI Connext for C# is based on CLI/C++ and it is not 100% compatible with Mono. 

Just wondering if that means that the C# classes generated by rtiddsgen from an .idl file won't work in Unity still, as Sara mentioned in 2017? 

Is this still the case, and for RTI DDS to work, developers can only use Connector? https://github.com/rticommunity/rticonnextdds-connector-cs

Also, if that is so, I was wondering if it would be possible to add a sample showing Connector working in a Unity project?

I've placed:

RTI.Connext.Connector.dll
and
Newtonsoft.Json.dll
 
In my Unity project Assets, but I keep getting an error message of:
 
"DllNotFoundException: rtiddsconnector

RTI.Connext.Connector.Interface.Connector+ConnectorPtr..ctor (System.String configName, System.String configFile) (at <6764437bb1b649d99d0d1a325bf196a8>:0)
RTI.Connext.Connector.Interface.Connector..ctor (System.String configName, System.String configFile) (at <6764437bb1b649d99d0d1a325bf196a8>:0)
RTI.Connext.Connector.Connector..ctor (System.String configName, System.String configFile) (at <6764437bb1b649d99d0d1a325bf196a8>:0)
PublishMessage..ctor () (at Assets/Scenes/PublishMessage.cs:13)"

 
As far as I can see, the DLL appears to be there, but perhaps my project setup is somehow incorrect?
 
Thank you.

 

Offline
Last seen: 2 months 2 weeks ago
Joined: 04/02/2013
Posts: 194

Correct, Connector doesn't use rtiddsgen-generated IDL types. The types are always configured in XML and accessed via the Connector API.

Regarding the DLL issue, have you tried adding the path to the Connector DLL to the PATH environment variable?

 

Offline
Last seen: 4 years 5 months ago
Joined: 10/01/2019
Posts: 5

Hi Alejandro,

Thanks for answering! My question was actually if I can use rtiddsgen IDL types directly with Unity (not through Connector)? Since what I'm building is essentially based off of generated .idl files?

I'll try adding the Connector DLL PATH and let you know!

Best regards.

Offline
Last seen: 4 years 5 months ago
Joined: 10/01/2019
Posts: 5

Hi Alejandro,

I added the rtiddsconnector.dll from here (https://github.com/rticommunity/rticonnextdds-connector/tree/master/lib) to my environment PATH, and it still did not work. I still received the same error message.

[EDIT: I was wrong, it works correctly now. Unity was being odd as I had to close and re-open Unity to see it. Thank you!]

 

So going back to my original question: can I use rtiddsgen generated C# files directly with Unity (not through Connector)? Or is the set up still not compatible with Mono? I'd prefer not to use Connector since I have an automated environment that generates idl files, and then calls rtiddsgen on it.

Offline
Last seen: 1 year 1 month ago
Joined: 10/22/2018
Posts: 91

Hi Jade,

I am no expert in Unity, but above in this thread it was mentioned that the reason that our generated C# code cannot be used with Unity is due to the fact it is a mix of unmanaged and managed code.
This is still the case with our C# API, so unless something has changed on the Mono end then it will not be possible to integrate Unity with our rtiddsgen generated C# code.

It is possible to use rtiddsgen to convert IDL -> XML (using the -convertToXml command line option). Maybe this is something you can integrate into your automated environment to allow you to use Connector?

Offline
Last seen: 4 years 5 months ago
Joined: 10/01/2019
Posts: 5

Hi Samr,

Much appreciated for verifying, yes, I suspected it was so, and I didn't realize at first that Unity doesn't support mixed assemblies (due to Mono). Thanks for the tip on IDL->XML, I'll look into that and see if that works for the flow I am trying to create.

Offline
Last seen: 4 years 5 months ago
Joined: 10/01/2019
Posts: 5

May any of you know what may cause a SEHException when creating a connector?

SEHException: Error creating connector
RTI.Connext.Connector.Interface.Connector..ctor (System.String configName, System.String configFile) (at <6764437bb1b649d99d0d1a325bf196a8>:0)
RTI.Connext.Connector.Connector..ctor (System.String configName, System.String configFile) (at <6764437bb1b649d99d0d1a325bf196a8>:0)
PublishMessage.Start () (at Assets/Scenes/PublishMessage.cs:20)

It's used in a simple instantiation:

using UnityEngine;
using RTI.Connext.Connector;

 

public class PublishMessage : MonoBehaviour
{
    const string configPath = "/Scenes/Configuration.xml";
    const string topic = "HelloWorld RTI";

    void Start() {
        string path = Application.dataPath;
        Connector connector = new Connector(topic, path + configPath);
    }
}

Offline
Last seen: 1 year 1 month ago
Joined: 10/22/2018
Posts: 91

Hi Jade,

It looks like you are creating the Connector object incorrectly. The first argument should be the name of the Connector conifguration in the XML file (i.e., the name in the ) which you supply in configPath.

If you look at this example, we create the connector as var connector = new Connector(configName, configPath)  where configName is "MyParticipantLibrary::Zero" -- this is formed as the names of the DomainParticipant library and Domain Participant in the XML configuration file.

Hope that helps,

Sam

Offline
Last seen: 3 years 9 months ago
Joined: 11/24/2019
Posts: 11

I am trying to establish a connection between Unity and DDS using RTI C# Connector. For this, I followed the steps below in order:

1-) I cloned the repository and compiled the API as stated in the documentation.

2-) RTI.Connext.Connector.dll was imported into Unity (Assets/Plugins folder) and  C:\rticonnextdds-connector-cs\rticonnextdds-connector\lib\x64Win64VS2013 added to environment PATH.

I have done the steps correctly but I get this error:

Cannot create connector: System.Runtime.InteropServices.SEHException (0x80004005): Error creating connector at RTI.Connext.Connector.Interface.Connector..ctor (System.String configName, System.String configFile) [0x00026] in C:\rticonnextdds-connector-cs\src\Connector\Interface\Connector.cs:29 at RTI.Connext.Connector.Connector..ctor (System.String configName, System.String configFile) [0x00044] in C:\rticonnextdds-connector-cs\src\Connector\Connector.cs:39

 

public class MotionControl : MonoBehaviour {

string configPath = "/Scenes/USER_QOS_PROFILES.xml";
string configName = "MyParticipantLibrary::SubscriptionParticipant";

void Start()
{
try
{
Connector connector = new Connector(configName, configPath);
RTI.Connext.Connector.Input reader = connector.GetInput(readerName);

}
catch (Exception e)
{
Debug.LogError($"Cannot create connector: {e}");
return;
}

}


I created a program other than Unity, tried the C # Connector and it is working properly. But I get an error when trying to use the  C# Connector in Unity. What could be the reason for this?

Howard's picture
Offline
Last seen: 12 hours 34 min ago
Joined: 11/29/2012
Posts: 565

Sorry if this is too little, too late...but you should check that your PATH has the the directory containing RTI Connext DDS DLLS needed by the RTI Connector.  Make sure you have the right architecture as well, i86Win32VS2010 is very different than x64Win64VS2012.  Make sure that you use the same architecture that the RTI Connector binary was compiled with as the RTI Connext DDS DLLs.

Not sure if the Unity development environment mucks with the path that's used to search for DLLs, if so, then you probably need to configure the paths within the Unity development tool correctly independent of the PATH environment variable.