Introduction
Lightning Fast Compilation and Module Management is a great asset that for developers working on large projects who need flexibility and to divide the scripts into self contained libraries that compile separately and potentially stored as an independent subrepository. It is also useful for scripting assets creators to manage their work.
This is the documentation, you can check the official tutorials here.
The plugin has a free open source version that you can get on the assetstore or bitbucket and a pro version.
Lightning Fast Compilation and Module Management for Unity makes you create Fast Compilation self contained asset with those features:
Features
- Flexibility of having source code with the speed of having a compiled DLL
- You can have editor code along with runtime code in the same library
- Use platform and custom defined directives as you wish in your asset code
- Your asset can be a self contained git subrepository that integrates easily in multiple game’s codes
- If you were using a DLL before, with the new Fast Compilation DLL you can have the same project and you don’t have to re-assign Monobehaviours
- With ‘Lightning Fast Compilation and Module Management for Unity’ you will have your DLL compiled and linked with the running version of Unity’s assemblies avoiding any compatibility issues
- Ability to store plugin code in the same sub folder as your asset (not compatible with assembly definition files yet)
- Handling custom scripting define symbols for each library independent of player settings (not compatible with assembly definition files yet)
- Compatibility with assembly definition files introduced to Unity 2017.3 (Pro Only)
- Converting your existing scripting asset into Fast Compilation Assets (Pro Only)
- .net 4.0 compatibility (currently pro only but will be added to free version soon)
- If you have your library in DLL before and convert it to fast compilation library, it can have the same id so you don’t have to reassign
You can get it from unity asset store here
Imagine your next big game code. You probably are using a lot of assets code, a lot of your own modular code, and a lot of third party libraries. Things can get messy especially if you need to customize a third party asset or library code for a particular game and manage them as sub-repositories.
Another problem is everything have to be recompiled if you even added a single line of code to test something out. That can be a nuisance in your Edit Code -> Play Test cycle.
You might think that compiling some code to DLL solve some of those problems, and you are right, but what if you have updated some define symbols to the source code of the DLL? You will need to leave unity, open visual studio, change the define symbols manually to match unity and recompile, which is quite nuisance if you ask me. Our asset is to automate and organize those kind of processes with a versioning system friendly approach.
This asset handles that problem better than Assembly Definition offered by recent unity version in the following:
Fast Compilation:
The Fast Compilation plugin is responsible for creating a fast compilation library. The directory structure of a fast compilation asset is as follows:
- Assets
- Fast Compilation Library Name
- .git (if you are using this library as a git submodule)
- Fast Compilation Library Name.asset
- VisualStudioFiles~
- NonPlugins
- Editor (source goes into this folder or subfolders)
- FastCompileDLLEditor.csproj (add to .gitignore)
- Runtime (source goes into this folder or subfolders)
- FastCompileDLL.csproj (add to .gitignore)
- Editor (source goes into this folder or subfolders)
- Plugins
- Editor (source goes into this folder or subfolders)
- FastCompilePluginDLLEditor.csproj (add to .gitignore)
- Runtime (source goes into this folder or subfolders)
- FastCompilePluginDLL.csproj (add to .gitignore)
- Editor (source goes into this folder or subfolders)
- FastCompileDLL.sln (add to .gitignore)
- NonPlugins
- Fast Compilation Library Name
A fast compilation library contains 4 primary modules, each one can be enabled or disabled individually
- Plugin Runtime
- C# Sources for this should be under Library Root/VisualStudioFiles~/Plugins/Runtime
- Plugin Editor
- C# Sources for this should be under Library Root/VisualStudioFiles~/Plugins/Editor
- depends on Plugin Runtime if it exists and enabled of the same Unity Fast Compilation Library.
- Runtime
- C# Sources for this should be under Library Root/VisualStudioFiles~/NonPlugins/Runtime
- depends on Plugin Runtime if it exists of the same Unity Fast Compilation Library.
- Editor
- C# Sources for this should be under Library Root/VisualStudioFiles~/NonPlugins/Editor
- depends on Plugin Runtime, Plugin Editor, Runtime if it exists and enabled of the same Unity Fast Compilation Library.
Creating a Fast Compilation Library
Choose Tools -> Fast Compilation -> Create New
Then enter the name of the library. You can customize the following options (described in details in the following sections) before hitting ‘Create’ button.
- Enable or Disable individual modules of the library. Refer to the module details above.
- Choose to Sync define symbols from player settings with the library
- Set new define symbols specific for the library
- Set GUIDs (you shouldn’t do that if you don’t know what you are doing)
- Set ‘Use Assembly Definition Files’ (Pro Only Feature) if you want to integrate with Unity 2017.3 assembly definition files but there will be some limitations check below
New libraries are put under Assets/LibraryName folder. If you want to put it in deeper directory you can name your library as follows
SubFolder.LibraryName
This will create the library under Assets/SubFolder/LibraryName
Extra Options
You can find extra options in the ‘New Fast Compilation Library Window’ and the same options after you have created the library in the ‘Fast Compilation Libraries List’ window.
Scripting Define Symbols
You have two options Sync Unity’s Scripting Define Symbols and Additional Scripting Define Symbols.
Sync Unity’s Scripting Define Symbols will take all the ‘Scripting Define Symbols’ in the player settings and apply it to the library when compiling.
Additional Scripting Define Symbols are the symbols you want to define specific to that library.
If ‘DEBUG’ is defined either in Player Settings with sync enabled, or in Additional Scripting Define Symbols, then the library will be built using debug build, otherwise it will be built using release build.
Enable/Disable Modules or Output Dlls
Each Library contains 4 modules Refer to the module details above.
For your specific library you might not need ‘Plugin’ or ‘Editor’ modules, in that case, just uncheck them.
Managing Dependencies
Your fast compilation libraries compilation wouldn’t include reference to your normal scripts in Unity. It will include references to the dlls loaded into Unity editor. If you want one Fast Compilation Library to use another Fast Compilation Library you should state dependencies as shown in the image above.
Choose your Fast Compilation Library, then drag the dependency from the list to the lower part of the window. Please make sure you don’t have loop dependencies.
Please check our plyGame tutorial for an example how to set dependencies correctly.
Writing Source
You can press ‘Project Folder’ and choose ‘Runtime Source Folder’ to open in Explorer the folder you should place the source files.
The csproj and sln files are created and updated automatically and you shouldn’t modify them directly.
Depending on the enabled modules, you will have different menu. The possible entries are
- Main Folder
- Runtime Source Folder
- Editor Source Folder
- Plugin Runtime Source Folder
- Plugin Editor Source Folder
Advanced Options
There can be up to 4 modules in a library. Runtime, Editor, Plugin Runtime, Plugin Editor.
Refer to the module details above.
The advanced options we have controls the GUIDs of the generated dlls in those 4 categories.
You will mostly be fine with the default GUIDs, but in some cases you might want to assign your own GUID. Once assigned you shouldn’t change it because changing the GUID will make problems with assigned ScriptableObjects and MonoBehaviours.
Interoperability with Older DLLs
If you had a compiled dll before and now you are using this asset to produce the same dll, you want to use the same GUID as your older DLL. To do that press “Get from .meta file”, then choose your older DLL meta file. This can’t be done if you created a fast compilation library using Assembly Definition Files. In the future a conversion will be added.
Assembly Definition Files Integration (Pro Only)
If you are using Assembly Definition Files please note the following differences from not using it
- Plugin Runtime and Plugin Editor are not compatible right now with assembly definition files integration
- Assembly Definition Files are not compiled using this asset, but Unity does the compilation. If you were using dlls then converted to asmdef you can’t use previous DLL guid and you might have to reassign MonoBehavirous from your previous DLLs.
- You can’t use your own custom scripting define symbols and the player setting’s scripting define symbols are always synced which is a current limitation with assembly definition files.
- If you were having your library before in unity in source code, an advantage of using assembly definition files is that you won’t need to change any MonoBehavior or ScriptableObject reference in your game objects or assets
You can create a fast compilation library using assembly definition files integration by checking ‘Use Assembly Definition Files’ box in the new dialogue, but you can’t change it later.
Converting Your Library to Fast Compilation Library (Pro Only)
If you have your library or asset distributed in source in unity you can convert it to fast compilation library with the following procedure.
- First create a new fast compilation library.
- Press ‘Project Folder’ -> ‘Main Folder’
- Move your unity cs source files under this Main Folder
- Unfold Advanced Settings
- Press ‘Convert CS Files in Library Directory’ which will convert those files into fast compilation library into Runtime and Editor categories.
If your original source files are under one folder, you can create your new library in the same folder, then directly click ‘Convert CS Files in Library Directory’
This procedure doesn’t support automatic converting for Assets/Plugin source code if the asset also include source inside Assets/Plugin. But you can do that manually using the following steps
- Checking Plugin Runtime (and Plugin Editor) if needed
- Press ‘Project Folder’ and choose ‘Plugin Runtime Source Folder’ or ‘Plugin Editor Source Folder’ as needed
- Then move your plugin source code into the appropriate folder but you will have to manually separate editor and runtime sources
Using With GIT
Make sure to ignore the generated .sln and .csproj inside VisualStudioFiles~. Easiest way is to create a new .gitignore file inside VisualStudioFiles~ and add to it .sln and .csproj.
Please check the official tutorials here.