Flax for Unity® developers
Flax and Unity have many similarities (C# scripting, physics engine) and share many concepts, however there are a few differences. This page helps Unity Engine developers to translate their existing Unity experience into the world of Flax Engine.
Warning
Warning! You will love the direction and development speed of this engine!
Editor
Flax Editor and Unity Editor are very similar. You can see the color-coded, highlighted areas on screenshots of both editors that have common functionalities. Flax Editor layout is also highly customizable so you can drag and drop windows around to adapt the editor to your workflow.
Tip
With the Flax Editor, enjoy instant play mode.
Terminology
This section contains the most common terms used in Unity and their Flax equivalents (or rough equivalents). Flax keywords link directly to more in-depth information inside the documentation.
Unity | Flax |
---|---|
GameObject | Actor |
MonoBehaviour | Script |
Shader | Material |
Material | Material Instance |
Hierarchy Panel | Scene Window |
Inspector | Properties Window |
Project Browser | Content Window |
Scene View | Viewport |
SRP/HDRP | Graphics |
Project
Flax projects structure is similar to Unity projects. Instead of Library folder, editor uses Cache folder. Also Assets folder from Unity is splitted into two separate parts: Content and Source. All C# script files are located in the source directory so there is less mess with assets and scripts.
Flax also generates a solution and project files for your game C# scripts.
See Flax projects structure page to learn more about the projects in Flax Engine.
Assets
Flax doesn't use .meta
files. Instead, every asset contains all required metadata information and is a self contained file. Files with the extension .flax
are using our own binary format that is well optimized for scalability and streaming. Other assets are usually stored in Json
format (scenes, settings, etc.).
Flax supports the most popular asset file formats (for 3D models and textures) so you can import your game content.
See Assets page to learn more about importing and using game assets.
GameObject vs Actor
Flax doesn't use components to build scene objects logic. We use Actors. Each Actor has its own type (e.g. point light, box collider) and a collection of attached scripts. Also there is no TransformComponent but Actors have built-in transformation (less objects, more optimized design for bigger games). This means, in Flax the scene objects hierarchy is created with Actors, not by Transforms like in Unity.
However, you can still use the entity-component design with your scripts because every actor can have scripts like in Unity.
Just instead of using GetComponent<T>()
in your scripts, write GetChild<T>()
/GetScript<T>()
.
In Flax, a Scene object is also an Actor so you can access it like any other Actor. This means that Scenes can have their own scripts and be transformed like other objects.
Tip
Flax's coordinate system's base unit is centimeters instead of meters, meaning a Flax Actor placed at <100,100,100> is in the equivalent position of a Unity Transform placed at <1,1,1>.
MonoBehaviour vs Script
When it comes to game scripting, Unity and Flax are very similar. There are some differences in C# API (Flax has bigger math library, is more performance-oriented and uses new C# 12 via .NET 8). In fact, the whole C# editor and C++ engine including scripting API is open and can be found here. All contributions are welcome.
Also, Flax support native C++ scripting and Visual Scripting as a built-in feature. We don't want to limit our developers to just one programming language for the game development as using C++ and Visual Scripting together with C# can benefit.
If you write C# scripts simply replace MonoBehaviour
with Script
as it makes more sense (and is shorter to write).
Unity
public class MyScript : MonoBehaviour { void Start() { Debug.Log("It is Unity!"); } }
Flax
public class MyScript : Script { public override void OnStart() { Debug.Log("It is Flax!"); } }
See Scripting documentation to learn more about C# scripts in Flax.
Cool things in the C# API
If you're a programmer here is a list of new cool things in Flax C# API that may be useful:
- You can use the latest .NET 8 and new C# 12
- Engine and Editor are open with full source code (link)
- You can edit all input settings at runtime (link)
- You can change the gamepad devices layout at runtime (link)
- You can dynamically set Update/Draw/Physics FPS (link)
- You can serialize/deserialize any objects to json (link)
- You can use a huge math library (link)
- You can perform custom rendering on GPU (link)
- You can use Custom Editors pipeline to create great editor extensions (link)
Unity® is a trademark of Unity Technologies.