- Home /
Implement M2MQTT for Unity
I started working with Unity. For this project, I need an MQTT connection. So I wanted to add M2MQTT for Unity. When opening an included test scene everything works fine, also writing new scripts. But when trying to implement the library to Unity for a blanked new project it fails. Every time new errors and I can't even build it. In the link below you'll find the library I want to use. Can you PLEASE help with including this library to Unity? I can't find help via Google...
Answer by CodesCove · Sep 04, 2020 at 11:44 PM
Make sure you copy both the M2Mqtt and M2MqttUnity/Scripts folders to you projects Asset folder.
To prevent namespace errors add text "SSL" to the Project Settings --> Player --> Other Settings --> Scripting Define Symbols. This is because the some of the scripts use this for #if directives
Also check that your API compatibility level is set to .NET 4.x.
THANK YOU SO $$anonymous$$UCH! Everything works now. Without your help I would never have thought of it.
Hi, may I ask you another question? I’m trying to fix it since a few days and don’t get it. I asked you one comment below for helping me with $$anonymous$$QTT in VR - do you have any idea? Thank you for helping!
Answer by xKingGx · Sep 11, 2020 at 07:22 PM
@CodesCove Could I ask you another question to M2MQTT?
Everything works well but when trying to configure it on my Oculus Quest (Android) it doesn't work with SSL. (After clicking on "Android" - "Switch platform" I saw, that there're some Android and VR explanations in this readme but I don't get how to set it up.
Could you please help me another time? Sorry for asking again, but your last tipp was optimal.
Hi, Didn't notice your another question so took a while to answer. Anyway if the problem still exists then here are some directions:
Switching platform will reset at least some of the player settings So check again that you have SSL defined. In addition check Project Settings --> Player --> XR Settings check the Virtual Reality supported and press + and select Oculus. The sdk will be installed automatically. At least the errors should disappear.