jacksondunstan / UnityNativeScripting

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

BootScript cannot be disabled #37

Closed sekkit closed 5 years ago

sekkit commented 5 years ago

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.

jacksondunstan commented 5 years ago

Thanks for pointing this out. BootScript was starting the native plugin on Awake instead of Start. I've fixed that in d67249bde28778803d894eb336cac50be9f40b87.

sekkit commented 5 years ago

OK. Why not implement it upon Unity runtime startup instead of Monobehaviour?

jacksondunstan commented 5 years ago

BootScript is an optional component for convenience sake. All you really need to do is call Bindings.Open, Bindings.AutoReload, Bindings.Close at some points in time. If you'd rather do this at different points than BootScript does, feel free to remove it from your scene and make the calls yourself.

sekkit commented 5 years ago

confirmed working with python on iOS, so far. Very nice project, great work. BUT i wanna mention why use json file to export types? you can use clr reflection to export all of the clr dlls, json file could be used to exclude stuff you don't wanna export.

image

jacksondunstan commented 5 years ago

Thanks for the kind words about the project and congratulations on getting it running on macOS!

As for why the JSON config file is a whitelist rather than a blacklist, there are definitely pros and cons to that decision. A whitelist means the bindings generator runs much faster and produces much less C++ so compile times and binaries are much smaller. A blacklist means there's less to configure and the project is easier to use because configuration can be somewhat complex.

There's room for compromise though. For example, the bindings generator could be made to optionally operate on blacklist JSON configs. Or an option could be added to the existing config to export an entire assembly. Or dependencies of some exported elements could be automatically discovered and exported, greatly reducing the need for manual configuration.