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
+44-35Lines changed: 44 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,10 +58,11 @@ While IL2CPP transforms C# into C++ already, it generates a lot of overhead. The
58
58
59
59
## Industry Standard Language
60
60
61
-
C++ is the standard language for video games as well as many other fields. By programming in C++ you can more easily transfer your skills and code to and from non-Unity projects. For example, you can avoid lock-in by using the same language (C++) that you'd use in the Unreal or Lumberyard engines.
61
+
C++ is the standard language for video games as well as many other fields. By programming in C++ you can more easily transfer your skills and code to and from non-Unity projects. For example, you can avoid lock-in by using the same language (C++) that you'd use in the [Unreal](https://www.unrealengine.com) or [Lumberyard](https://aws.amazon.com/lumberyard/) engines.
62
62
63
63
# UnityNativeScripting Features
64
64
65
+
* Code generator exposes any C# API to C++
65
66
* Supports Windows, macOS, Linux, iOS, and Android (editor and standalone)
66
67
* Works with Unity 2017.x and 5.x
67
68
* Plays nice with other C# scripts- no need to use 100% C++
@@ -85,26 +86,48 @@ C++ is the standard language for video games as well as many other fields. By pr
85
86
86
87
* Platform-dependent compilation via the [usual flags](https://docs.unity3d.com/Manual/PlatformDependentCompilation.html) (e.g. `#if UNITY_EDITOR`)
87
88
*[CMake](https://cmake.org/) build system sets up any IDE project or command-line build
88
-
* 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:
89
-
* Class types
90
-
* Struct types
91
-
* Enumeration types
92
-
* Base classes
93
-
* Constructors
94
-
* Methods
95
-
* Fields
96
-
* Properties (getters and setters)
97
-
*`out` and `ref` parameters
98
-
* Exceptions
99
-
* Overloaded operators
100
-
* Arrays (single- and multi-dimensional)
101
-
* Delegates
102
-
* Events
103
-
* Boxing and unboxing (e.g. casting `int` to `object` and visa versa)
104
-
* Implementing C# interfaces with C++ classes
105
-
* Deriving from C# classes with C++ classes
106
-
* Default parameters
107
-
* Generic types and methods
89
+
90
+
# Code Generator
91
+
92
+
The core of this project is a code generator. It generates C# and C++ code called "bindings" that make C# APIs available to C++ game code. It supports a wide range of language features:
93
+
94
+
* Types
95
+
* `class`
96
+
* `struct`
97
+
* `enum`
98
+
* Arrays (single- and multi-dimensional)
99
+
* Delegates (e.g. `Action`)
100
+
* `decimal`
101
+
* Type Contents
102
+
* Constructors
103
+
* Methods
104
+
* Fields
105
+
* Properties (`get` and `set` like `obj.x`)
106
+
* Indexers (`get` and `set` like `obj[x]`)
107
+
* Events (`add` and `remove` delegates)
108
+
* Overloaded operators
109
+
* Boxing and unboxing (e.g. casting `int` to `object` and visa versa)
110
+
* Function Features
111
+
* `out` and `ref` parameters
112
+
* Generic types and methods
113
+
* Default parameters
114
+
* Cross-Language Features
115
+
* Exceptions (C# to C++ and C++ to C#)
116
+
* Implementing C# interfaces with C++ classes
117
+
* Deriving from C# classes with C++ classes
118
+
119
+
Note that the code generator does not yet support:
120
+
121
+
*`Array`, `string`, and `object` methods (e.g. `GetHashCode`)
122
+
* Non-null string default parameters and null non-string default parameters
To configure the code generator, open `Unity/Assets/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.
129
+
130
+
To run the code generator, choose `NativeScript > Generate Bindings` from the Unity editor.
108
131
109
132
# Performance
110
133
@@ -194,20 +217,6 @@ With C++, the workflow looks like this:
194
217
6. The build scripts or IDE project files are now generated in your build directory
195
218
7. Build as appropriate for your generator. For example, execute `make` if you chose `Unix Makefiles` as your generator.
196
219
197
-
# The Code Generator
198
-
199
-
To run the code generator, choose `NativeScript > Generate Bindings` from the Unity editor.
200
-
201
-
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.
202
-
203
-
Note that the code generator does not support (yet):
204
-
205
-
*`Array`, `string`, and `object` methods (e.g. `GetHashCode`)
206
-
* Non-null string default parameters and null non-string default parameters
To update to a new version of this project, overwrite your Unity project's `Assets/NativeScript` directory with this project's `Unity/Assets/NativeScript` directory and re-run the code generator.
0 commit comments