You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-22Lines changed: 21 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,8 @@ A significant amount of effort is required to work around the GC and the resulti
33
33
34
34
C++ has no required garbage collector and features optional automatic memory management via "smart pointer" types like [shared_ptr](http://en.cppreference.com/w/cpp/memory/shared_ptr). It offers excellent alternatives to Unity's primitive garbage collector.
35
35
36
+
While using some .NET APIs will still involve garbage creation, the problem is contained to only those APIs rather than being a pervasive issue for all your code.
37
+
36
38
## Total Control
37
39
38
40
By using C++ directly, you gain complete control over the code the CPU will execute. It's much easier to generate optimal code with a C++ compiler than with a C# compiler, IL2CPP, and finally a C++ compiler. Cut out the middle-man and you can take advantage of compiler intrinsics or assembly to directly write machine code using powerful CPU features like [SIMD](http://jacksondunstan.com/articles/3890) and hardware AES encryption for massive performance gains.
@@ -66,7 +68,6 @@ While IL2CPP transforms C# into C++ already, it generates a lot of overhead. The
66
68
transform.SetPosition(position);
67
69
68
70
* No need to reload the Unity editor when changing C++
69
-
* Code generator exposes any C# API (Unity, .NET, custom DLLs) with a simple JSON config file
70
71
* Handle `MonoBehaviour` messages in C++
71
72
72
73
>
@@ -77,12 +78,27 @@ While IL2CPP transforms C# into C++ already, it generates a lot of overhead. The
77
78
78
79
* Platform-dependent compilation via the [usual flags](https://docs.unity3d.com/Manual/PlatformDependentCompilation.html) (e.g. `#if UNITY_EDITOR`)
79
80
*[CMake](https://cmake.org/) build system sets up any IDE project or command-line build
81
+
* Code generator exposes any C# API (Unity, .NET, custom DLLs) with a simple JSON config file and runs from a menu in the Unity editor. It supports a wide range of features:
82
+
* Class types
83
+
* Struct types
84
+
* Enumeration types
85
+
* Base classes
86
+
* Constructors
87
+
* Methods
88
+
* Fields
89
+
* Properties (getters and setters)
90
+
*`MonoBehaviour` classes with "message" functions like `Update`
Most projects will see a net performance win by reducing garbage collection, eliminating IL2CPP overhead, and access to compiler intrinsics and assembly. Calls from C++ into C# incur a minor performance penalty, so if most of your code is calls to .NET APIs then you may experience a net performance loss.
84
100
85
-
tl;dr - Most projects will not be noticeably impacted by C++ overhead and many projects will benefit from reducing garbage collection, eliminating IL2CPP overhead, and access to compiler intrinsics and assembly.
101
+
For testing and benchmarks, see this [article](http://jacksondunstan.com/articles/3952).
86
102
87
103
# Project Structure
88
104
@@ -170,24 +186,7 @@ To run the code generator, choose `NativeScript > Generate Bindings` from the Un
170
186
171
187
To configure the code generator, open `NativeScriptTypes.json` and notice the existing examples. Add on to this file to expose more C# APIs from Unity, .NET, or custom DLLs to your C++ code.
172
188
173
-
The code generator supports:
174
-
175
-
* Class types (including generics)
176
-
* Struct types (including generics)
177
-
* Base classes (including generics)
178
-
* Constructors (including generic parameters)
179
-
* Methods (including generic parameters and return types)
180
-
* Fields (including generic types)
181
-
* Properties (getters and setters) (including generic types)
182
-
*`MonoBehaviour` classes with "message" functions like `Update`
183
-
*`out` and `ref` parameters
184
-
* Enumerations
185
-
* Exceptions
186
-
* Overloaded operators
187
-
* Arrays (single- and multi-dimensional)
188
-
* Delegates
189
-
190
-
The code generator does not support (yet):
189
+
Note that the code generator does not support (yet):
191
190
192
191
* Events
193
192
* Boxing and unboxing (e.g. boxing `int` to `object`, casting `object` to `int`)
@@ -196,7 +195,7 @@ The code generator does not support (yet):
0 commit comments