Wasin Thonkaew

Ask me!   Making stuff @haxpor

Debugging Unity game with native plugin. Even the sdk is mobile-based but I modified it to make it be able to build to desktop platform.
As you know if the sdk is data oriented, you have no need to use native capability for every api call. Thus this...

Debugging Unity game with native plugin. Even the sdk is mobile-based but I modified it to make it be able to build to desktop platform.

As you know if the sdk is data oriented, you have no need to use native capability for every api call. Thus this will work and reduce a loooot of time in debugging the game.

Do that!

— 2 years ago
#unity  #plugin  #native 
A little but important warning from Unity itself.
A native plugin is only loaded once and never unloaded. Thus you have to restart Unity. I spent several hours trying to get it works but no chance as I didn’t restart Unity.
Thus if you’re native...

A little but important warning from Unity itself.

A native plugin is only loaded once and never unloaded. Thus you have to restart Unity. I spent several hours trying to get it works but no chance as I didn’t restart Unity.

Thus if you’re native plugin developer on Unity. When you update your library code, and need to try again. Make sure you restart Unity.

— 2 years ago
#unity  #plugin  #native 
Unity Plugin Note 2

It seems creating plugin for Android is easier than iOS. Less boilerplate code, and research time.

In iOS, major time is to spend finding a way to pass and do random access to array. I found it to pass as pointer, accept on C# as IntPtr and do random access on array via addition of size of data type (struct is easiest) to pointer and cast it via MarShal.PtrToStructure. It works but lots of boilerplate code.

In Android, it seems like AndroidJavaProxy is the way to go to inherit that class to accept return response back from API. Then it’s all yours. Just properly parse data and send back. Lots less boilerplate code.

Interesting question is why on Android has less boilerplate code. It might be because of using AndroidJavaProxy that helps and contain everything we want. But I ever looked at JNI. To be honest, that’s a lot more to get to work and it’s low level than this.

Good JNI example is Flurry for cocos2dx at https://github.com/diwu/AnalyticX.

— 2 years ago
#unity  #plugin  #ios  #android 
Unity’s Plugin Callback

I need to remind myself regarding the development of plugin for Unity.

Even the callback executed from unmanaged code (C/C++/ObjC/ObjC++), the callback method is only in static environment even I mark it as non-static one whatsoever. Its member variable still cannot be accessed within the method. That tells all the story.

So always static for callback declaration in C# code, and treat it as that. No time will be wasted.

— 2 years ago
#unity  #plugin 
Today my working desk looks like this …

Today my working desk looks like this …

— 3 years ago with 2 notes