Skip to content

fix(unity): compile WebGL players without MQTTnet - #2058

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/unity-push-webgl
Oct 15, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/unity-push-webgl

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

MQTTnet.dll is left out of WebGL players, but Push imported it on every platform, so WebGL builds failed to compile.

#if !UNITY_WEBGL || UNITY_EDITOR
using MQTTnet;
// ...
    public class Push : MonoBehaviour { /* MQTT implementation */ }
#else
    public class Push : MonoBehaviour
    {
        // same public API; Subscribe fails with PlatformNotSupportedException("Push is not supported on WebGL")
    }
#endif

Client imports System.Text.Json on every platform, but it and its four managed dependencies were also left out of WebGL, so they are now enabled there. MQTTnet.dll stays off WebGL.

Test: testUnityImportsPluginsLeftOutOfWebglOnlyOffWebgl fails on main (Push.cs imports mqttnet, and Client.cs imports system.text.json with only the guard). The generated Push.cs compiles with UNITY_WEBGL defined. GenerationTest passes (110 tests).

Closes #2060

MQTTnet.dll is left out of WebGL players, so Push now uses it only off WebGL and WebGL gets a Push whose subscribe fails with PlatformNotSupportedException. The managed System.Text.Json dependencies, which Client already imports on every platform, are enabled for WebGL.
@hansi-codes

hansi-codes Bot commented Oct 15, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The WebGL-specific implementation preserves the Push API, the plugin metadata aligns with the guarded code, and the generation test covers the new platform boundary.

The Unity templates now conditionally exclude the MQTT-backed Push implementation from WebGL players and provide a Push stub whose subscribe methods return PlatformNotSupportedException. The System.Text.Json assemblies and their managed dependencies are enabled for WebGL, and a generation test checks plugin imports against platform availability.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
templates/unity/Assets/Runtime/Push.cs.twig Guards MQTT imports and implementation off WebGL players and adds the unsupported Push implementation.
templates/unity/Assets/Runtime/Core/Plugins/*.dll.meta Enables the System.Text.Json runtime and managed dependencies for WebGL while leaving MQTTnet excluded.
tests/generation/GenerationTest.php Adds coverage for imports of plugins excluded from WebGL players.

Reviewed 3132f9a · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 15, 2026
@ChiragAgg5k
ChiragAgg5k merged commit 8dacf70 into main Oct 15, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile Unity WebGL players without MQTTnet

1 participant