jacksondunstan / UnityNativeScripting

Unity Scripting in C++
https://jacksondunstan.com/articles/3938
MIT License
1.33k stars 135 forks source link

Project needs minor updates for Unity 2019.1.8f1 #30

Closed ip closed 5 years ago

ip commented 5 years ago

Seems the projects needs minor update for Unity 2019.1.8.

I followed the "Getting started" section in README. There are 3 issues I noticed.

Issue 1 GenerateBindings.cs didn't compile because of this line (commented out): image After I commented it out and shifted the array indices accordingly I was able to generate the bindings.

Issue 2 image

When I commented this out, everything started to work.

Issue 3 (not blocking) One more strange thing is that pressing "Reload native plugin" button in the editor throws an exception, but it's not actually needed (at least on mac) as the game always use the recent version of the plugin. The exception:

NullReferenceException: Object reference not set to an instance of an object
System.Runtime.InteropServices.Marshal.WriteInt64 (System.IntPtr ptr, System.Int32 ofs, System.Int64 val) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Runtime.InteropServices.Marshal.WriteIntPtr (System.IntPtr ptr, System.Int32 ofs, System.IntPtr val) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
NativeScript.Bindings.OpenPlugin (NativeScript.Bindings+InitMode initMode) (at Assets/NativeScript/Bindings.cs:706)
NativeScript.Bindings.Reload () (at Assets/NativeScript/Bindings.cs:638)
NativeScript.Editor.EditorMenus.Reload () (at Assets/NativeScript/Editor/EditorMenus.cs:27)

Sorry if I'm missing something, I didn't read the docs too thoroughly, just wanted to get the thing working. I actually want to make Haskell bindings to Unity 😄

jacksondunstan commented 5 years ago

Hi @ip, thanks for reporting these issues!

Issue 1 I just pushed commit 7b3d95ec3ca559a543262b2dcc36daf4808c113f to fix this. It was caused by Unity changing the namespace of that class to move it out of Experimental.

Issue 2 I don't get that compiler error. I also don't see IDeserializationCallback. Is this something you added in your NativeScriptTypes.json?

Issue 3 I don't get this exception when I reload the plugin on macOS. I wonder what could explain why you do. Any ideas?

Good luck with your Haskell bindings! -Jackson

ip commented 5 years ago

Thank you, will check it out