简体   繁体   中英

Which backend scripting build is required for Websocket-sharp? (IL2CPP or .NET)

I am writing an application where I need to throw information using websockets. I came across the websocket-sharp library . As given in the guide, I have put the .dll file inside the Assets/Plugins/ location. However, often it happens that after a restart of my system of unity, it starts throwing error the Websocket sharp namespace or directive could not be found . I have to reimport or copy and paste. Also some of the related scripts or resources based on Websockt sharp like unityros , while building with .NET backend scripting fails to build throwing errors for includes like:

using System.Threading
using WebsocketSharp

a fix I found was to use:

#if UNITY_EDITOR
   using System.Threading
   using WebsocketSharp
#endif

and also need to add functions within the same if and endif conditions that use those include headers (sorry I am a C++ language guy - apologies for the terminologies like include headers) . But no error is thrown when I build these projects with setting backend scripting to IL2CPP from the Unity Player Settings .

Can I use an IL2CPP file for deploying it in MR devices like hololens? Build configuration for MR devices would be Release, x64, Remote Device . Kindly advise.

The problem you described in your question has nothing to do with using IL2CPP or .NET as backend.

The biggest issue is that System.Threading is not supported on HoloLens. HoloLens uses UWP which has many .NET API stripped out so you must use UNITY_EDITOR directive to remove any code that uses it when building for platforms that do not support.

Use MessageWebSocket when building for HoloLens and the websocket-sharp for other platform. See MessageWebSocket github for many examples on how to use that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM