Skip to main content

Visual Studio Solution File

Motivation

A crucial part of Unity Playworks Plugin export process is compiling project scripts written in C# into JavaScript. In order to minimize changes required to the original codebase and smoothen developers' experience, Unity Playworks Plugin contains a set of .NET libraries that are compatible with UnityEngine.dll on the API level. That means your code can invoke functions, read constants and values and do other things without changes as if they were invoked against "real" UnityEngine.dll.

However, Plugin is not a 100% replicate of Unity Engine for multiple reasons: performance, availability of certain APIs on the Web platform, obsolescence of some parts of the engine and so on. That renders a possibility of the code failing to compile against Luna's version of Unity runtime.

In most cases it is very easy to work around specific missing APIs by replacing them with available alternatives or even simply disabling parts of the code that aren't critical for the final product. This, however, requires manual intervention and Plugin is doing its best to make this process as approachable as possible.

Suggested workflow

In order to debug the compilation step and keep developers in the environment they are comfortable working in, Unity Playworks Plugin generates a separate solution file configured with all relevant C# files from the project.

Developers can then open that solution file using their IDE of choice should compilation fail.

When you encounter a compilation error, you will be prompted by a popup:

plugin-ui-code

Hitting "Show Report" button will open the Project Diagnostics, similarly to Unity's console. Here you will find a breakdown of the compilation errors.

plugin-ui-code

At any time from here, navigate to the Code tab and hit the Open Playworks Plugin Solution button. This will launch your default IDE with the Playworks Plugin Solution loaded.

plugin-ui-code

The solution is set up in such a way that the following always holds true:

  • All C# scripts are linked into the solution. You can change them here without the need to propagate the changes back to Unity's files.
  • Instead of "original" UnityEngine.dll, Luna's version is used. That means you can trigger a build from the IDE to see if the errors go away, code completion also works out of the box and so on.

Upon opening a solution and triggering a rebuild, developers are presented with the exact errors that stop Unity Playworks Plugin from compiling the project:

plugin-ui-code

Code completion hints are also available automatically:

images-medium

At Luna, we have found this setup extremely convenient to iterate on the code and make fixes whenever required.