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
Add support for MonoBehaviour classes and their messages to the code generator
Add basic support for generic method return values to the code generator
Remove MonoBehaviourUpdate and PluginUpdate
Add a version
Add README sections for features, performance, JSON configuration, and contributing
tl;dr - Most projects will not be noticeably impacted by C++ overhead and many projects will benefit from reducing garbage collection and IL2CPP overhead.
56
+
29
57
# Project Structure
30
58
31
59
When scripting in C++, C# is used only as a "binding" layer so Unity can call C++ functions and C++ functions can call the Unity API. A code generator is used to generate most of these bindings according to the needs of your project.
@@ -101,6 +129,49 @@ There's nothing to do for iOS!
101
129
6. The build scripts or IDE project files are now generated in your build directory
102
130
7. Build as appropriate for your generator. For example, execute `make` if you chose `Unix Makefiles` as your generator.
103
131
132
+
# Configuring the Code Generator
133
+
134
+
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.
135
+
136
+
The code generator supports:
137
+
138
+
* Class types (i.e. Classes with methods, etc. Parameters, etc. are fine.)
139
+
* Constructors
140
+
* Methods
141
+
* Fields
142
+
* Properties (getters and setters)
143
+
* Generic return types
144
+
*`MonoBehaviour` classes with "message" functions (except `OnAudioFilterRead`)
145
+
146
+
The code generator does not support (yet):
147
+
148
+
* Struct types
149
+
* Arrays (single- or multi-dimensional)
150
+
* Generic functions and types
151
+
*`out` and `ref` parameters
152
+
* Delegates
153
+
*`MonoBehaviour` contents (e.g. fields) except for "message" functions
154
+
155
+
The JSON file is laid out as follows:
156
+
157
+
* Path - Absolute path to the DLL
158
+
* Types - Array of types in the DLL to generate
159
+
* Name - Name of the type including namespace (e.g. `UnityEngine.GameObject`)
160
+
* Constructors - Array of constructors to generate
161
+
* Types - Parameter types of the constructor including namespace
162
+
* Methods - Array of methods to generate
163
+
* Name - Name of the method
164
+
* ParamTypes - Parameter types to the method including namespace
165
+
* GenericTypes - Sets of type parameters to generate
166
+
* Name - Name of the type parameter (e.g. `T`)
167
+
* Type - Type to generate for the type parameter including namespace
168
+
* Properties - Array of property names to generate
169
+
* Fields - Array of field names to generate
170
+
* MonoBehaviours
171
+
* Name - Name of the `MonoBehaviour` class to generate
172
+
* Namespace - Namespace to put the `MonoBehaviour` class in
173
+
* Messages - Array of message names to generate (e.g. `Update`)
174
+
104
175
# Updating To A New Version
105
176
106
177
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.
@@ -113,6 +184,10 @@ To update to a new version of this project, overwrite your Unity project's `Asse
113
184
114
185
[Jackson Dunstan](http://jacksondunstan.com)
115
186
187
+
# Contributing
188
+
189
+
Please feel free to fork and send [pull requests](https://github.com/jacksondunstan/UnityNativeScripting/pulls) or simply submit an [issue](https://github.com/jacksondunstan/UnityNativeScripting/issues) for features or bug fixes.
190
+
116
191
# License
117
192
118
193
All code is licensed [MIT](https://opensource.org/licenses/MIT), which means it can usually be easily used in commercial and non-commercial applications.
0 commit comments