Skip to main content

Posts

Showing posts with the label Unity

Thinking in ECS

If you have been following the new developments in the Unity Game engine, you would have found that they have been focusing on performance and modular code. One of the outcomes of this is a new way of writing code called "Entity Component System" where "Systems" operate on "Entities" which have various "Components" within them.  The ECS name is specific to Unity naming convention this "paradigm" also goes by the name of "Data oriented Programming". This could easily be mapped to how "C" programming works, or in general any functional programming works i guess.. "Systems" == "Functions" "Entities" == "Structures" "Components" == "Data Types / Unions" If we had to write a game engine in C i believe any reasonable programmer would write it this way, there would be an array of structures which contain the "position, rotation, scale" informatio...

Unity Game (WebGL) as a Firefox Extension

Firefox is known for its' extensions. That's in fact one of the main reasons people still use it. They had to take a bunch of bold steps in the recent times to stay relavant, like ending support for older extensions, changing the security model and the api. Firefox  announced a new contest for addons, The Firefox Quantum Extensions challenge. I thought ill' give it a shot. I quickly looked up the documentation for creating an extension and looked pretty simple, there was this game for 2048 i was super excited to put games as extension, quick access short games might workout  i thought.. I wanted to check if i could use my existing game dev tools to create an extension.. hence Unity for FF Extension. I quickly exported unity game as WebGL and tried loading it as an extension. I ran into issues with something called CSP i don't remember seeing it before but here it was preventing me from loading the unity webgl game as firefox extension. After a bunch of mucking arou...

Unity Plugin Android(Part2)

In my last post iv'e covered about how to write a plugin without actually over-riding the unity activities so you can peacefully co-exist with other unity plugins (for android). The reality is that you will have to deal with people using Prime31 as one of their plugins. This can be a problem if you need to get callbacks for the android system event callbacks like: void onCreate(Bundle Intent){ } void onStart(){ } void onStop(){ } and so on. You get the idea. Fortunately the prime31 guys provide us a method for registering a class to get callbacks from these methods on the activity. The details of which are provided at the following url https://gist.github.com/prime31/0908e6100d7e228f1add/raw/a5d96177c8d8fde548068d2a15de49acdb2023ec/Android+Activity+Sharing This is pretty straight forward If you know how to use Android ADT/Eclipse for creating android projects. Here is how you go about it. 1) First create an Android Project. Mark it as a library project. 2) Add ...

Unity Plugin (Android)

I've been working on creating a plugin for unity(Android). The latest versions of unity (4.x) provide clean way of accessing the java side of things on android. If you want access to the android activity from android,  all you have to do is call the following.. AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unityPlayer.GetStatic ("currentActivity"); This doesn't give us much of a head way... i.e, if you want to add any functionality you will have to extend the UnityPlayerActivity and add the functions you want and call them. But there is a more elegant way of doing it. You can just create a jar file from your android library and access its' functionality like so.. AndroidJavaClass   _pluginClass = new AndroidJavaClass ( "com.vkgamedev.MyTestLib.MyTestLib" ); _pluginClass.CallStatic( "setGoogleProjectId" , googleProjectId); If your  libr...