FlexCompiler
website·Indexed 31 days ago
https://compiler.flexframework.netA Unity 3D editor extension designed to streamline the development process for asset publishers and game developers. It provides tools for project management, C# compilation, and a robust extension system allowing for custom symbols, references, visibility changes, and assembly obfuscation. It includes programmatic access via the FlexFramework.FlexCompiler namespace.
What's inside FlexCompiler
- Extensions in FlexCompiler allow developers to extend the capabilities of the C# compiler. They operate by subscribing to specific job hooks and updating the associated context. Extensions can be enabled/disabled via the extensions panel and reordered via drag-and-drop to resolve execution conflicts within the same hook (executing from top to bottom).
Overview of FlexCompiler for Unity 3D
FlexCompiler is a Unity 3D editor extension that streamlines the C# compilation process. It allows developers and asset publishers to generate compiled assemblies by adding scripts to the project panel and clicking "Run," removing the manual overhead of assembly management.Modify type visibility using the Visibility Changer extension
The Visibility Changer extension modifies syntax trees during the compilation creation hook to change the visibility level of top-level types. It uses a strategy to determine the visibility shift and a target mask to filter which types are affected.Access FlexCompiler programmatically in Unity
FlexCompiler is available under theFlexFramework.FlexCompilernamespace. Because it is an editor-only reference, any code utilizing these APIs must be placed within an 'Editor' folder in the Unity project.Remove source files from the sources panel
To remove files or folders from the sources panel:
- Select the target entries. Use "Shift" or "Control (Command)" to select multiple items.
- Click the "-" button at the bottom-right corner to remove the selection.
Note: Scripts that are missing from the project are marked with warning icons. These must be removed manually using the "-" button if they are no longer needed.
Add source scripts to FlexCompiler
Source scripts can be added to the project using two methods:
- Sources Tab: Click the "+" button in the sources tab to browse and select scripts.
- Drag and Drop: Drag scripts directly from the Unity Project panel into the FlexCompiler sources panel.
When adding a folder, all nested scripts are included automatically. Note that changes to the folder's contents (adding, deleting, or renaming scripts) are not tracked automatically and require the folder to be re-added. Duplicate scripts are ignored.
Build and Export FlexCompiler projects
To compile the project, click the 'Run' button at the bottom of the window and monitor the Unity console for the result. To save the project configuration for later use, click 'Export Project' at the bottom-right corner (this option is only available if the sources panel contains at least one script).Open the FlexCompiler Project Editor
To launch the project configuration window, navigate to the Unity menu: Window -> FlexCompiler -> Project Editor.Extend FlexCompiler functionality
FlexCompiler includes an extension system that supports dependency projects and code obfuscation. Developers can create custom compiler extensions directly within the Unity editor to add specialized behavior to the compilation pipeline.Manage projects in the FlexCompiler GUI
FlexCompiler provides basic project management via the project window:
- Create New: A new empty project is automatically created on first launch. To start a new project later, click New Project (bottom-left). Warning: Current unsaved changes will be discarded.
- Import: Click Import Project (bottom-center) to load an existing
.fcxmlfile. Warning: Current unsaved changes will be discarded. - Export/Save: Click Export Project (bottom-right). This is required to persist changes to an imported project or save current work, as edits are only stored in a temporary cache until exported. The export option is only enabled when the sources panel is not empty.
Import legacy project files from version 1.x
The Legacy Project Importer is a global extension that allows users to load project files created in version 1.x. Once this extension is enabled, the project import dialog will include support for the.fpjfile extension.Manage compilation settings and projects in FlexCompiler
FlexCompiler provides customizable compiler settings to tailor the compilation process to specific project needs. It includes built-in import and export features to simplify project management within the Unity editor.