πŸ‘οΈ | Code Analyzer

How to find issues and incompatibilities in your WebGL Unity game?

Trail Analyzer is a Roslyn-based code analyzer for .NET C# projects (designed specifically for Unity Games) to identify any Trail platform and WebGL incompatibilities.

When porting, you'll sometimes find that WebGL doesn't support all of your game's libraries or functionalities. Sadly, Unity does not warn you of these incompatibilities, often leading to difficult-to-troubleshoot errors.

The Trail Code Analyzer adds warnings into both Unity and Visual Studio for known incompatibilities -- saving you time in both research and troubleshooting.

πŸ“˜

Continuous Expansion

The Code Analyzer scans your code, searching for known incompatibilities. As Trail ports games and learns more, the set of rules is continuously expanded to further accelerate your WebGL porting. The Trail Code Analyzer lets you gain Trail's knowledge without yourself having to blindly explore.

Installing & Using the Trail Code Analyzer

1) Download the Trail Code Analyzer (.tgz package)

2) Install the package through Unity's built-in Package Manager > + icon > Add package from tarball...

3) Done! You'll now get automatic warnings when using webGL-incompatible methods.

517517

Window > Package Manager > + icon > Add package from tarball > Select Trail Code Analyzer Tgz (Problem? Click here!)

πŸ‘

Warnings as you'd expect

After adding the analyzer to your Unity project, you'll get warnings in both Unity and IDE when WebGL-incompatible code is used. This is the type of functionality you'd expect from Unity and .NET C# solutions, but doesn't exist for WebGL without the Trail Code Analyzer.

878878

The analyzer creates what you'd expect in Unity; warnings and errors when your code won't behave as intended.

834834

The Code Analyzer will also create warnings in the Visual Studio Editor & error list!

Analyzer Diagnostics

Diagnostic IDTitleCategory
TRAIL0001Task.Delay is not supported on WebGLThreading
TRAIL0002Task.Run is not supported on WebGLThreading
TRAIL0003Task.Factory.StartNew is not supported on WebGLThreading
TRAIL0004Thread.Sleep can cause unpredictable behaviour on WebGLThreading
TRAIL0005Task Parallel Library is not supported on WebGLThreading

πŸ“˜

Fixes to Diagnostic Warnings

The default fix to problems is automatically recommended inside your IDE; suppress the code by commenting it out or replacing the code. If there is a great default solution, it will be added as an automatic suggestion!