Unity Scripting in C++

Unity Native Scripting

A library to allow writing Unity scripts in native code: C, C++, assembly.

Purpose

This project aims to give you a viable alternative to C#. Scripting in C++ isn't right for all parts of every project, but now it's an option.

Goals

  • Make scripting in C++ as easy as C#
  • Low performance overhead
  • Easy integration with any Unity project
  • Fast compile, build, and code generation times
  • Don't lose support from Unity Technologies

Reasons to Prefer C++ Over C#

Fast Device Build Times

Changing one line of C# code requires you to make a new build of the game. Typical Android build times tend to be at least 10 minutes because IL2CPP has to run and then a huge amount of C++ must be compiled.

By using C++, we can compile the game as a C++ plugin in about 1 second, swap the plugin into the APK, and then immediately install and run the game. That's a huge productivity boost!

Fast Compile Times

C++ compiles much more quickly than C#. Incremental builds when just one file changes-- the most common builds-- can be 15x faster than with C#. Faster compilation adds up over time to productivity gains. Quicker iteration times make it easier to stay in the "flow" of programming.

No Garbage Collector

Unity's garbage collector is mandatory and has a lot of problems. It's slow, runs on the main thread, collects all garbage at once, fragments the heap, and never shrinks the heap. So your game will experience "frame hitches" and eventually you'll run out of memory and crash.

A significant amount of effort is required to work around the GC and the resulting code is difficult to maintain and slow. This includes techniques like object pools, which essentially make memory management manual. You've also got to avoid boxing value types like int to to managed types like object, not use foreach loops in some situations, and various other gotchas.

C++ has no required garbage collector and features optional automatic memory management via "smart pointer" types like shared_ptr. It offers excellent alternatives to Unity's primitive garbage collector.

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.

Total Control

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 and hardware AES encryption for massive performance gains.

More Features

C++ is a much larger language than C# and some developers will prefer having more tools at their disposal. Here are a few differences:

  • Its template system is much more powerful than C# generics
  • There are macros for extreme flexibility by generating code
  • Cheap function pointers instead of heavyweight delegates
  • No-overhead algorithms instead of LINQ
  • Bit fields for easy memory savings
  • Pointers and never-null references instead of just managed references
  • Much more. C++ is huge.

No IL2CPP Surprises

While IL2CPP transforms C# into C++ already, it generates a lot of overhead. There are many surprises if you read through the generated C++. For example, there's overhead for any function using a static variable and an extra two pointers are stored at the beginning of every class. The same goes for all sorts of features such as sizeof(), mandatory null checks, and so forth. Instead, you could write C++ directly and not need to work around IL2CPP.

Industry Standard Language

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.

UnityNativeScripting Features

  • Code generator exposes any C# API to C++
  • Supports Windows, macOS, Linux, iOS, and Android (editor and standalone)
  • Works with Unity 2017.x and 5.x
  • Plays nice with other C# scripts- no need to use 100% C++
  • Object-oriented API just like in C#
GameObject go;
Transform transform = go.GetTransform();
Vector3 position(1.0f, 2.0f, 3.0f);
transform.SetPosition(position);
  • Hot reloading: change C++ without restarting the game
  • Handle MonoBehaviour messages in C++
void MyScript::Start()
{
	String message("MyScript has started");
	Debug::Log(message);
}
  • Platform-dependent compilation (e.g. #if TARGET_OS_ANDROID)
  • CMake build system sets up any IDE project or command-line build

Code Generator

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:

  • Types
    • class
    • struct
    • enum
    • Arrays (single- and multi-dimensional)
    • Delegates (e.g. Action)
    • decimal
  • Type Contents
    • Constructors
    • Methods
    • Fields
    • Properties (get and set like obj.x)
    • Indexers (get and set like obj[x])
    • Events (add and remove delegates)
    • Overloaded operators
    • Boxing and unboxing (e.g. casting int to object and visa versa)
  • Function Features
    • out and ref parameters
    • Generic types and methods
    • Default parameters
  • Cross-Language Features
    • Exceptions (C# to C++ and C++ to C#)
    • Implementing C# interfaces with C++ classes
    • Deriving from C# classes with C++ classes

Note that the code generator does not yet support:

  • Array, string, and object methods (e.g. GetHashCode)
  • Non-null string default parameters and null non-string default parameters
  • Implicit params parameter (a.k.a. "var args") passing
  • C# pointers
  • Nested types
  • Down-casting

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.

To run the code generator, choose NativeScript > Generate Bindings from the Unity editor.

Performance

Almost all 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 only a minor performance penalty. In the rare case that almost all of your code is calls to .NET APIs then you may experience a net performance loss.

Testing and benchmarks article

Optimizations article

Project Structure

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.

All of your code, plus a few bindings, will exist in a single "native" C++ plugin. When you change your C++ code, you'll build this plugin and then play the game in the editor or in a deployed build (e.g. to an Android device). There won't be any C# code for Unity to compile unless you run the code generator, which is infrequent.

The standard C# workflow looks like this:

  1. Edit C# code in a C# IDE like MonoDevelop
  2. Switch to the Unity editor window
  3. Wait for the compile to finish (slow, "real" games take 5+ seconds)
  4. Run the game

With C++, the workflow looks like this:

  1. Edit C++ code in a C++ IDE like Xcode or Visual Studio
  2. Build the C++ plugin (extremely fast, often under 1 second)
  3. Switch to the Unity editor window. Nothing to compile.
  4. Run the game

Getting Started

  1. Download or clone this repo
  2. Copy everything in Unity/Assets directory to your Unity project's Assets directory
  3. Edit NativeScriptTypes.json and specify what parts of the Unity, .NET, and custom DLL APIs you want access to from C++.
  4. Edit Unity/Assets/CppSource/Game/Game.cpp and Unity/Assets/CppSource/Game/Game.h to create your game. Some example code is provided, but feel free to delete it. You can add more C++ source (.cpp) and header (.h) files here as your game grows.

Building the C++ Plugin

iOS

  1. Install CMake version 3.6 or greater
  2. Create a directory for build files. Anywhere is fine.
  3. Open the Terminal app in /Applications/Utilities
  4. Execute cd /path/to/your/build/directory
  5. Execute cmake -G MyGenerator -DCMAKE_TOOLCHAIN_FILE=/path/to/your/project/CppSource/iOS.cmake /path/to/your/project/CppSource. Replace MyGenerator with the generator of your choice. To see the options, execute cmake --help and look at the list at the bottom. Common choices include "Unix Makefiles" to build from command line or "Xcode" to use Apple's IDE.
  6. The build scripts or IDE project files are now generated in your build directory
  7. Build as appropriate for your generator. For example, execute make if you chose Unix Makefiles as your generator or open NativeScript.xcodeproj and click Product > Build if you chose Xcode.

macOS (Editor and Standalone)

  1. Install CMake version 3.6 or greater
  2. Create a directory for build files. Anywhere is fine.
  3. Open the Terminal app in /Applications/Utilities
  4. Execute cd /path/to/your/build/directory
  5. Execute cmake -G "MyGenerator" -DEDITOR=TRUE /path/to/your/project/CppSource. Replace MyGenerator with the generator of your choice. To see the options, execute cmake --help and look at the list at the bottom. Common choices include "Unix Makefiles" to build from command line or "Xcode" to use Apple's IDE. Remove -DEDITOR=TRUE for standalone builds.
  6. The build scripts or IDE project files are now generated in your build directory
  7. Build as appropriate for your generator. For example, execute make if you chose Unix Makefiles as your generator or open NativeScript.xcodeproj and click Product > Build if you chose Xcode.

Windows (Editor and Standalone)

  1. Install CMake version 3.6 or greater
  2. Create a directory for build files. Anywhere is fine.
  3. Open a Command Prompt by clicking the Start button, typing "Command Prompt", then clicking the app
  4. Execute cd /path/to/your/build/directory
  5. Execute cmake -G "Visual Studio VERSION YEAR Win64" -DEDITOR=TRUE /path/to/your/project/CppSource. Replace VERSION and YEAR with the version of Visual Studio you want to use. To see the options, execute cmake --help and look at the list at the bottom. For example, use "Visual Studio 15 2017 Win64" for Visual Studio 2017. Any version, including Community, works just fine. Remove -DEDITOR=TRUE for standalone builds. If you are using Visual Studio 2019, execute cmake -G "Visual Studio 16" -A "x64" -DEDITOR=TRUE /path/to/your/project/CppSource instead.
  6. The project files are now generated in your build directory
  7. Open NativeScript.sln and click Build > Build Solution.

Linux (Editor and Standalone)

  1. Install CMake version 3.6 or greater
  2. Create a directory for build files. Anywhere is fine.
  3. Open a terminal as appropriate for your Linux distribution
  4. Execute cd /path/to/your/build/directory
  5. Execute cmake -G "MyGenerator" -DEDITOR=TRUE /path/to/your/project/CppSource. Replace MyGenerator with the generator of your choice. To see the options, execute cmake --help and look at the list at the bottom. The most common choice is "Unix Makefiles" to build from command line, but there are IDE options too. Remove -DEDITOR=TRUE for standalone builds.
  6. The build scripts or IDE project files are now generated in your build directory
  7. Build as appropriate for your generator. For example, execute make if you chose Unix Makefiles as your generator.

Android

  1. Install CMake version 3.6 or greater
  2. Create a directory for build files. Anywhere is fine.
  3. Open a terminal (macOS, Linux) or Command Prompt (Windows)
  4. Execute cd /path/to/your/build/directory
  5. Execute cmake -G MyGenerator -DANDROID_NDK=/path/to/android/ndk /path/to/your/project/CppSource. Replace MyGenerator with the generator of your choice. To see the options, execute cmake --help and look at the list at the bottom. To make a build for any platform other than Android, omit the -DANDROID_NDK=/path/to/android/ndk part.
  6. The build scripts or IDE project files are now generated in your build directory
  7. Build as appropriate for your generator. For example, execute make if you chose Unix Makefiles as your generator.

Updating To A New Version

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.

Reference

Articles by the author describing the development of this project.

Author

Jackson Dunstan

Contributing

Please feel free to fork and send pull requests or simply submit an issue for features or bug fixes.

License

All code is licensed MIT, which means it can usually be easily used in commercial and non-commercial applications.

All writing is licensed CC BY 4.0, which means it can be used as long as attribution is given.

Comments
  • UnityEngineTimePropertyGetDeltaTime's return type is wrong

    UnityEngineTimePropertyGetDeltaTime's return type is wrong

    Hi! When the NativeScript.dll is used, Unity always crashes because the C++ UnityEngineTimePropertyGetDeltaTime function pointer's return type is System::Single which is diffrent from the return type of the C# delegate UnityEngineTimePropertyGetDeltaTimeDelegateType. UnityEngineTimePropertyGetDeltaTime should return float instead of System::Single.

  • [Need merge back feature]Frequently crash with memory linkedlist

    [Need merge back feature]Frequently crash with memory linkedlist

    image

    If i do not call addcomponent, it worked well. But when I addcomponent(a monobehaviour added to scene), and stop playing, and replaying, this issue will ocur.

  • No PlacementNew alternative

    No PlacementNew alternative

    The lib I imported into UnityNativeScripting conflicts with new operator when compiling in Windows(VC15) BUT it compiles fine with Xcode. So I need to bypass this placement new trick. Any idea would be great^^

    	{
    		MyGame::BaseBallScript* memory = Plugin::StoreWholeBaseBallScript(); 
    		//MyGame::BallScript* thiz = new (memory) MyGame::BallScript(Plugin::InternalUse::Only, handle); 
    		//return thiz->CppHandle;
    		MyGame::BallScript* thiz = new (memory) MyGame::BallScript(Plugin::InternalUse::Only, handle);
    		return 0;
    	}
  • Performance question - Having lots of c++ monobehaviour's is slower than expected.

    Performance question - Having lots of c++ monobehaviour's is slower than expected.

    Hello,

    I am planning on using your project for lua bindings instead of moonsharp. As a quick test to see how fast it runs, I spawned 1,000 GameObjects with the BaseBall script.

    I also changed the object store both in c# and c++ to allow up to 10,00 objects.

    The result was poor, each script was taking 0.078 ms in Editor and 0.070 ms in the Il2cpp build.

    I then implemented the BaseBall script in C# and performed the same test.

    My results where much better. each script was taking about 0.01 ms to complete in Editor.

    This is my first time trying something like this in Unity3d, I read your blog and it looked like you where getting much better results "C++ can still make 13,140 Unity API calls in a single millisecond.". Executing the c++ scripts is taking me 70 - 80 ms, this seems wrong to me.

    Is it better to only have one monobehaviour that manages multiple game objects?

  • CodeGen Compatibilty breaks

    CodeGen Compatibilty breaks

    NativeScriptTypes.zip

    With this config and master codebase no any change, Editor runs fine, il2cpp standalone build crashes, mono standalone build throughs error like this:

    image

    If add VisualElement to Types, c++ bindings won't compile at all.

  • Couldn't open Native Library

    Couldn't open Native Library

    Hi, I'm posting this issue because I don't know why, Unity refuses to load the Native Library, is it because the architecture is x86 ? I did set the project to x86 though so I don't think this is the reason.

    image

  • Build products problem

    Build products problem

    Now,all platforms build successfully,but run error: iOS: DllNotFoundException: Unable to load DLL 'NativeScript': The specified module could not be found. at NativeScript.Bindings.Init (System.IntPtr memory, System.Int32 memorySize, NativeScript.Bindings+InitMode initMode, System.IntPtr releaseObject, System.IntPtr stringNew, System.IntPtr setException, System.IntPtr arrayGetLength, System.IntPtr enumerableGetEnumerator, System.Int32 maxManagedObjects, System.IntPtr releaseSystemDecimal, System.IntPtr systemDecimalConstructorSystemDouble, System.IntPtr systemDecimalConstructorSystemUInt64, System.IntPtr boxDecimal, System.IntPtr unboxDecimal, System.IntPtr unityEngineVector3ConstructorSystemSingle_SystemSingle_SystemSingle, System.IntPtr unityEngineVector3Methodop_AdditionUnityEngineVector3_UnityEngineVector3, System.IntPtr boxVector3, System.IntPtr unboxVector3, System.IntPtr unityEngineObjectPropertyGetName, System.IntPtr unityEngineObjectPropertySetName, System.IntPtr unityEngineComponentPropertyGetTransform, System.IntPtr unityEngineTransformPropertyGetPosition, System.IntPtr unityEngineTransformPropertySetPosition, System.IntPtr systemCollectionsIEnumeratorPropertyGetCurrent, System.IntPtr systemCollectionsIEnumeratorMethodMoveNext, System.IntPtr unityEngineGameObjectMethodAddComponentMyGameBaseBallScript, System.IntPtr unityEngineGameObjectMethodCreatePrimitiveUnityEnginePrimitiveType, System.IntPtr unityEngineDebugMethodLogSystemObject, System.IntPtr unityEngineMonoBehaviourPropertyGetTransform, System.IntPtr systemExceptionConstructorSystemString, System.IntPtr boxPrimitiveType, System.IntPtr unboxPrimitiveType, System.IntPtr unityEngineTimePropertyGetDeltaTime, System.IntPtr releaseBaseBallScript, System.IntPtr baseBallScriptConstructor, System.IntPtr boxBoolean, System.IntPtr unboxBoolean, System.IntPtr boxSByte, System.IntPtr unboxSByte, System.IntPtr boxByte, System.IntPtr unboxByte, System.IntPtr boxInt16, System.IntPtr unboxInt16, System.IntPtr boxUInt16, System.IntPtr unboxUInt16, System.IntPtr boxInt32, System.IntPtr unboxInt32, System.IntPtr boxUInt32, System.IntPtr unboxUInt32, System.IntPtr boxInt64, System.IntPtr unboxInt64, System.IntPtr boxUInt64, System.IntPtr unboxUInt64, System.IntPtr boxChar, System.IntPtr unboxChar, System.IntPtr boxSingle, System.IntPtr unboxSingle, System.IntPtr boxDouble, System.IntPtr unboxDouble) [0x00000] in <00000000000000000000000000000000>:0 at NativeScript.Bindings.OpenPlugin (NativeScript.Bindings+InitMode initMode) [0x00000] in <00000000000000000000000000000000>:0

    (Filename: currently not available on il2cpp Line: -1)

    Setting up 2 worker threads for Enlighten. Thread -> id: 700009a85000 -> priority: 1 Thread -> id: 700009b08000 -> priority: 1 2018-05-02 13:59:44.571819+0800 unityplayground[89052:1933499] [BoringSSL] Function boringssl_session_errorlog: line 2881 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert 2018-05-02 13:59:44.572148+0800 unityplayground[89052:1933499] [BoringSSL] Function boringssl_session_errorlog: line 2881 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert

    I built macosx/iOS/Android,there are problems.

    Unity Net 3.5 or 4.6 ,Il2CPP or MONO

  • Using 2D arrays

    Using 2D arrays

    Hi,

    I'm using NativeScript in a project and I've notice a problem when using 2D arrays.

    In C# I'm defining 2D arrays as float[,] values but this generate System::Array2<System::Single, System::Single> in Bindings.h/cpp

    System::Array2<System::Single, System::Single> is not defined and it should generate System::Array2<System::Single>.

    Am I right ? Am I using 2D array as designed in generator ? Should I use float[][] instead of float[,] ?

    Regards,

  • [#51] Fix performance issue with Object Store

    [#51] Fix performance issue with Object Store

    When BaseMaxSimultaneous was set to a large number the object-store was spending to much time finding the handle. This was fixed using a dictionary where the keys have the objects full hash.

  • Convert System::String to c char string or std::string

    Convert System::String to c char string or std::string

    Hi, I need to implement that feature to interact System.string with C++ string, any idea of that? Found no api to do that, don't wanna implement in C# side, but I reckon conversion in C++ side should be more efficient.

    desc: //a System.String obj char *str = obj.c_str();

  • BootScript cannot be disabled

    BootScript cannot be disabled

    Steps to produce the issue: Uncheck BootScript in Unity Editor Inspector, and press Play button. The plugin's PluginMain is called anyway. The script is actually working nomatter it's active or not.

  • why  sometimes transform x, y stops working but z works fine?

    why sometimes transform x, y stops working but z works fine?

    Hey ! I noticed that sometimes unity transform do not read receive cpp vector 3 properly. Main issue Unity Transform component only reading Z but omitting X,Y . But when the cpp vector 3 sent to debug massage it works fine

    What's going on here!?

  • Bindings generator does not handle multiple derived types

    Bindings generator does not handle multiple derived types

    I've noticed when you have several classes based of the same abstract class the codegen can't handle it even thought the syntax looks like it should e.g.

    		{
    			"Name": "MyNamespace.AbstractShape",
    			"BaseTypes": [
    				{
    					"BaseName": "MyNamespace.BaseSquare",
    					"DerivedName": "MyNamespace.Square"
    				},
    				{
    					"BaseName": "MyNamespace.BaseCircle",
    					"DerivedName": "MyNamespace.Circle"
    				}
    			]
    		}
    

    Doesn't work

  • problem with calling typed method with arguments

    problem with calling typed method with arguments

    Hello,

    Generate bindings breaks when trying to generate the binding for a "method<>(args)", it works well with "method<>()".

    {
    				"Name": "UnityEngine.Object",
    				"Methods": [
    					{
    						"Name": "Instantiate",
    						"ParamTypes": [
    							"UnityEngine.Object"
    						],
                            "GenericParams": [
                                {
                                    "Types": [
    								 "UnityEngine.Component"
                                       
                                    ]
                                },
                                {
                                    "Types": [
                                        "UnityEngine.GameObject"
                                    ]
                                },
                                {
                                    "Types": [
                                        "UnityEngine.MeshRenderer"
                                    ]
                                },
                                {
                                    "Types": [
                                        "UnityEngine.ParticleSystem"
                                    ]
                                },
                                {
                                    "Types": [
                                        "UnityEngine.Light"
                                    ]
                                },
                                {
                                    "Types": [
                                        "UnityEngine.AudioSource"
                                    ]
                                },
                                {
                                    "Types": [
                                        "UnityEngine.TextMesh"
                                    ]
                                }
                            ]
    					}
    				]
    			}
    

    it doesnt find a matching method . the c# method is public static T Instantiate<>(T original) where T : Object; , on the UnityEngine.Object type;

    Thank you for helping ,

    Regards,

    Merlin

  • Crash in release build when returning a string from a method

    Crash in release build when returning a string from a method

    Hi, I am working on a project and I found a weird issue that only happens in release build

    I have a a function that returns a string image (Member is a string member I use quickly for this example but basically it happened with all my code) and it works in the editor, the string is properly returned and I can work with it, but when I test it in a standalone build, the game crashes immediatly when the function is called this is the log it generated when crashing

    error.log

  • Workflow improvement - Delete Bindings

    Workflow improvement - Delete Bindings

    The Issue

    When you create a new Abstract type for example AbstractBaseBallScript and you generate the bindings you get BaseBallScript In your Bindings.cs. Switching back to unity editor triggers a compilation and no errors. Good.

    If you add some more abstract functions to your AbstractBaseBallScript and switch back to unity editor to re-build your bindings. Unity Editor will have some Errors for you, but this does not prevent you from clicking on Generate Bindings. If you do generate bindings again GenerateBindings is accessing an older assembly without your changes to AbstractBaseBallScript. Thus Bindings.cs will not have your new changes and will continue to give compilation errors.

    The only way to fix this is to manually clear out your Bindings.cs , compile your code with no errors, then click Generate Bindings. This results with bindings that reflect your changes.

    One Potential Fix

    The way I have fixed this currently is by adding a new editor option NativeScript/Delete Bindings. I call InjectBuilders and have them clear out the bindings for me. Now I can delete the bindings and compile without errors. One problem that still persists is you still have to fix any other errors from referencing the bindings generated class from your code-base. In my case its just a factory function.

    I'm not sure if this is an already solved problem. I would like to know what your thoughts are on this.

    If you think the Delete Bindings is a good idea I can create another pull request as well.

  • [Critical] .Net4.x crashes

    [Critical] .Net4.x crashes

    Unity2018.4.5f1, MacOS works fine, but windows crashes.

    issue reproduce: When calling MyGameAbstractBaseBallScriptUpdate

    CSharp code:

                    public override void Update()
    		{
    			if (CppHandle != 0)
    			{
    				int thisHandle = CppHandle;
    				NativeScript.Bindings.MyGameAbstractBaseBallScriptUpdate(thisHandle);
    				if (NativeScript.Bindings.UnhandledCppException != null)
    				{
    					Exception ex = NativeScript.Bindings.UnhandledCppException;
    					NativeScript.Bindings.UnhandledCppException = null;
    					throw ex;
    				}
    			}
    		}
    
    

    When executes to the line: auto returnValue = Plugin::UnityEngineTimePropertyGetDeltaTime(); It crashes. C++ code:

    System::Single UnityEngine::Time::GetDeltaTime()
    	{
    		auto returnValue = Plugin::UnityEngineTimePropertyGetDeltaTime();
    		if (Plugin::unhandledCsharpException)
    		{
    			System::Exception* ex = Plugin::unhandledCsharpException;
    			Plugin::unhandledCsharpException = nullptr;
    			ex->ThrowReferenceToThis();
    			delete ex;
    		}
    		return returnValue;
    	}
    

    Exception thrown at 0x00007FFDE974D5D9 (NativeScript_temp.dll) in Unity.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

    Stacktrace:

    ========== OUTPUTTING STACK TRACE ==================
    
    0x00007FFE2AEBD5D9 (NativeScript_temp) [c:\projects\research\unitycpp\unity\libs\cppsource\nativescript\bindings.cpp:5498] UnityEngine::Time::GetDeltaTime 
    0x00007FFE2AEA3B9A (NativeScript_temp) [c:\projects\research\unitycpp\unity\libs\cppsource\game\game.cpp:38] MyGame::BallScript::Update 
    0x00007FFE2AEBFCA7 (NativeScript_temp) [c:\projects\research\unitycpp\unity\libs\cppsource\nativescript\bindings.cpp:5819] MyGameAbstractBaseBallScriptUpdate 
    0x000000004E2DC2C5 (Mono JIT Code) (wrapper managed-to-native) object:wrapper_native_00007FFE2AEA12AD (int)
    0x000000004E367898 (Mono JIT Code) [C:\Projects\Research\unitycpp\Unity\Assets\NativeScript\Bindings.cs:2121] MyGame.BaseBallScript:Update () 
    0x000000004EE32FC8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    0x00007FFDBABCB970 (mono-2.0-bdwgc) [c:\users\bokken\builds\vm\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke 
    0x00007FFDBAB51922 (mono-2.0-bdwgc) [c:\users\bokken\builds\vm\mono\mono\metadata\object.c:2919] do_runtime_invoke 
    0x00007FFDBAB5A91F (mono-2.0-bdwgc) [c:\users\bokken\builds\vm\mono\mono\metadata\object.c:2966] mono_runtime_invoke 
    0x0000000140C03DAA (Unity) scripting_method_invoke
    0x0000000140BF400A (Unity) ScriptingInvocation::Invoke
    0x0000000140BBCB57 (Unity) MonoBehaviour::CallMethodIfAvailable
    0x0000000140BBD271 (Unity) MonoBehaviour::CallUpdateMethod
    0x00000001406EEBDC (Unity) BaseBehaviourManager::CommonUpdate<BehaviourManager>
    0x00000001406F5266 (Unity) BehaviourManager::Update
    0x0000000140960373 (Unity) `InitPlayerLoopCallbacks'::`2'::UpdateScriptRunBehaviourUpdateRegistrator::Forward
    0x000000014095EFC7 (Unity) ExecutePlayerLoop
    0x000000014095F093 (Unity) ExecutePlayerLoop
    0x0000000140962351 (Unity) PlayerLoop
    0x0000000141349FDF (Unity) PlayerLoopController::UpdateScene
    0x0000000141339383 (Unity) PlayerLoopController::EnterPlayMode
    0x0000000141345323 (Unity) PlayerLoopController::SetIsPlaying
    0x0000000141348282 (Unity) Application::TickTimer
    0x00000001414A4C53 (Unity) MainMessageLoop
    0x00000001414A693D (Unity) WinMain
    0x000000014249BABA (Unity) __scrt_common_main_seh
    0x00007FFE3E237BD4 (KERNEL32) BaseThreadInitThunk
    0x00007FFE3EBCCE71 (ntdll) RtlUserThreadStart
    
    
    Game booted up
    UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    NativeScript.Bindings:UnityEngineDebugMethodLogSystemObject(Int32) (at Assets\NativeScript\Bindings.cs:1372)
    System.Object:wrapper_native_00007FFE2AEA18DE(IntPtr, Int32, InitMode)
    NativeScript.Bindings:OpenPlugin(InitMode) (at Assets\NativeScript\Bindings.cs:836)
    NativeScript.Bindings:Open(Int32) (at Assets\NativeScript\Bindings.cs:622)
    NativeScript.BootScript:Awake() (at Assets\NativeScript\BootScript.cs:36)
     
    (Filename: Assets/NativeScript/Bindings.cs Line: 1372)
    
    Crash!!!
A universal way to create a noclip mod in Unity games (Mono/IIL2CPP)

Universal-Unity-NoClip This projects aim to show how a noclip mod can be created in any unity game, regardless if its using an il2cpp or mono backend.

Nov 11, 2022
Adds proper Apple Pencil support to Unity's InputSystem.

This project aims to create an Apple Pencil device for Unity's InputSystem package. The problem: Unity does not fully integrate with Apple Pencil. App

Nov 19, 2022
A native plugin for Unity that provides simple packet division and restoration.

uPacketDivision This is a native plug-in that divides a given data (System.IntPtr or array) into specified sizes and restores them regardless of the i

Feb 20, 2022
Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research
Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research

Welcome to AirSim AirSim is a simulator for drones, cars and more, built on Unreal Engine (we now also have an experimental Unity release). It is open

Nov 25, 2022
Tests to check the determinism of the basic floating point arithmetic operations on different devices, using Unity and Rust.
Tests to check the determinism of the basic floating point arithmetic operations on different devices, using Unity and Rust.

This repo contains tests to check the determinism (consistency) of the basic floating point arithmetic operations (add, subtract, multiply, divide) on

Nov 6, 2022
Unity project with an example on how to run the depthai library in Android.
Unity project with an example on how to run the depthai library in Android.

depthai-android-unity-example Unity project (built with Unity 2020.3.25f1) with an example on how to run the depthai library in Android. Important Thi

Mar 13, 2022
Useful cmake macros that help with: compiler/linker flags, collecting sources, PCHs, Unity builds and other stuff.
Useful cmake macros that help with: compiler/linker flags, collecting sources, PCHs, Unity builds and other stuff.

ucm - useful cmake macros ucm is a collection of cmake macros that help with: managing compiler/linker flags collecting source files with grouping in

Nov 10, 2022
A lightweight additive chiptune synthesizer (LV2 and Unity Plugin)

OvenMit Synthesizer kenakofer's first ever synthesizer! Coming initially out of BMusic's excellent tutoral series for lv2 synthesizers, the developer

Oct 22, 2022
HLSL to GLSL language translator based on ATI's HLSL2GLSL. Used in Unity.

HLSL to GLSL shader language translator ⚠️ As of mid-2016, the project is unlikely to have any significant developments. At Unity we are moving to a d

Nov 24, 2022
GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.

GLSL optimizer ⚠️ As of mid-2016, the project is unlikely to have any significant developments. At Unity we are moving to a different shader compilati

Nov 27, 2022
Unity includes a 10,000 NPC scene

luacluster 概要 luacluster分布式游戏服务器框架。特色是实现了万人同屏,实现了无缝大地图,用户开发方式为lua的rpc调用模式,已经接入mongodb。近期计划是写技术白皮书。QQ群:927073440。 [TOC] 1. BUILDING AND INSTALLATION CM

Nov 26, 2022
A run-time API resolver for IL2CPP Unity.

IL2CPP Resolver A run-time API resolver for IL2CPP Unity. Quick Example #include "Main.hpp" void SomeFunction() { IL2CPP::Initialize(); // This n

Nov 18, 2022
Dynamic 3D cellular automata engine with lua scripting support
Dynamic 3D cellular automata engine with lua scripting support

Cell3D Cell3D is a dynamic 3D cellular automata engine with lua scripting support Installation Dependencies: Lua 5.3 Raylib Simplest possible build co

Oct 7, 2022
🎩 An interpreted general-purpose scripting language 🔨

Dunamis Version 0.0.0.2 - Alpha Version 1.1 An interpreted general-purpose programming language Contents Syntax Functions Variables Objects Enums Incl

Dec 21, 2021
a C++ scripting language

/>mpl setup />mpl requires CMake and a C++ compiler to build, rlwrap is highly recommended for running the REPL. $ cd ampl $ mkdir build $ cd build $

Nov 6, 2021
A scripting language written in C

News KGScript will be rewritten from scratch in C or C++ (a big update) Usage Usage: ./KGScript file.kgs [options] Examples prints("Example") printi(1

Nov 12, 2021
Simple, fast, JIT-compiled scripting language for game engines.
Simple, fast, JIT-compiled scripting language for game engines.

Aftel Aftel (acronym for «A Far Too Easy Language») is a programming language, primarily intended to serve as an embeddable scripting language for gam

May 20, 2022
ACL - A simple scripting language made in c++

ACL ACL is a simple and easy to learn language. ACL is a compiled language, made with C++. For code examples look at the examples/ folder. We would ap

Nov 1, 2022
The Wren Programming Language. Wren is a small, fast, class-based concurrent scripting language.

Wren is a small, fast, class-based concurrent scripting language Think Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a fami

Nov 29, 2022