Limitations in Playworks Plugin
The Unity Playworks Plugin engine has been built in-house by the Unity Playworks Plugin team, with the goal of allowing you to create your playable ads in Unity, and having the same output and experience in the browser.
There are a number of hard limitations that comes with this, as well as some APIs which we currently do not support.
Limitations
DLLs
DLLs are currently unsupported in Unity Playworks Plugin.
What can you do?
Replace the DLL with the plug-in C# source code. C++ plugins are not supported.
Ads and Analytics SDKs
Ads and Analytics SDKs are not supported in Playable ads, and therefore Unity Playworks Plugin does not support them.
What can you do?
You have a few options:
- Use Automatic Stubbing to remove the SDKs from your project.
- Wrap calls to these SDKs using
#if !UNITY_LUNA
. - Remove references to the SDKs entirely from your code.
What can you do?
- A work around is to re-bake the animations to target skinned mesh directly.
NavMesh
NavMesh is currently unsupported by Unity Playworks Plugin - whilst it is on the roadmap, it can be computationally expensive and so an alternative may be preferred for a playable experience.
What can you do?
- The A* C# plugin from the asset store is a great alternative, and has been tested by Plugin.
- Implement your logic manually in C#.
- Implement node-based Movement.
URP/HDRP
HDRP is currently unsupported, with no short term plans to add support.
What can you do?
Use Universal Render Pipeline or Unity's built-in Default render pipeline.
Shadows
Shadows are supported only for the built-in pipeline.
WebGL
While we support both WebGL 1 and WebGL 2 starting from Unity Playworks Plugin 6.0.0, there are some shader features we don't support yet:
- Uniform Locations
- Uniform Buffers
Precompiled Shaders
Shaders marked with Compiled code: none (Precompiled shaders) are not currently supported.
Using such shaders can produce Type error: Cannot read property val
of null. (on line offsetUnits.val)
Bridge Limitations
Unity Playworks Plugin transpiles C# code to JS with the Bridge.NET library, however Bridge only supports up to C# 7.0. This means features added in later releases (7.1, 7.2 etc.) will likely not be supported in Plugin.
For a list of C# 7.1+ features that we do support, click here.
Examples of such features, with workarounds for each:
Destructor (~TypeName method)
Example of unsupported behaviour:
class myClass {
~myClass() {}
}
One workaround for this would be to instead use OnDestroy()
.
GOTO statement
Example of unsupported behaviour:
switch (n)
{
case 1:
cost += 25;
break;
case 2:
cost += 25;
goto case 1;
case 3:
cost += 50;
goto case 1;
default:
Console.WriteLine("Invalid selection.");
break;
}
One workaround for this is to use functions in place of looping back:
private static void costUp(int n){
cost += n * 25;
}
if (n != null){
costUp(n)
}
In other cases it might be better to use recursion in place of goto logic.
Circular inheritance with interfaces
Example of unsupported behaviour:
interface A extends B {}
interface B extends A {}
To workaround this you will need to break such inheritance and rewrite the code without it.
Inline cast
When attempting an inline cast, be sure to have declared the variable prior to casting.
However to avoid complications we suggest avoiding inline casting entirely.
Example of what to do:
double varDouble = 2.3;
int varInt;
varInt = (int) varDouble;
Bridge Implemented Features
As previously mentioned, Unity Playworks Plugin transpiles C# code into JavaScript by using Bridge.NET library. Listed below is a list of all the C# 7.0-7.3 features that have been implemented or are planned to be implemented.
Playworks Plugin offers support for C# 7.0 features. Please refer to the C# documentation to see the differences between the various versions.
C# 7.0-7.3 features
Feature | Support |
---|---|
Out variables | Supported |
Tuples and deconstruction | Supported |
Pattern matching | Supported |
Local functions | Supported |
Expanded Expression-bodied members | Supported |
Ref locals and returns | Supported |
Discards | Supported |
Throw expressions | Supported |
Default Literal expressions | Supported |
In modifiers on parameters | Supported |
Non-trailing names arguments | Supported |
== and != with tuple types | Supported |
Unity Playworks Plugin Compiler V2
For more information C# 8.0/9.0 features, please check the Unity Playworks Plugin Compiler V2 guide.
Lighting
While lighting is supported, there are limitations surrounding the number of lights that have high intensity settings.
For example, if you have a light component and set its intensity to 1 and have additional lights in the scene as well, with intensities set to 1 or higher as these lights are summed in Unity Playworks Plugin causing over lit scenes in your Unity Playworks Plugin build.
This is a limitation of WebGL 1.0.
Unity GUI
Unity Playworks Plugin does not support the old Unity GUI system.
DOTS or ECS
We don't support Unity DOTs or ECS.