Blog of


Unity’s Mono maniacs

Be sure of one thing: I love Unity and cannot let a day end without doing something with it^^.
But: there's a but.
I'm very disappointed about the transparency regarding its mono version, integration and... modification.
Everything in Unity is well documented, tutorialized, blogged and tweeted... everything but Mono !

What are we talking about exactly ?

Unity is using the C# language, but it stand on top of a modified version of Mono 2.6 .
Mono ( is a framework : a utility toolkit that extends the language/compiler by high-abstraction primitives, like List, Dictionaries, garbage collector, Self-Introspection.
Mono was made as an open-source alternative to the .NET Framework, made by Microsoft (which also became open-source recently ! sources here )
You can see Mono as the foundation of Unity's kernel, and its secret recipe for its huge portability.

So, I have one request and one only:

As Unity provides its manual documentation : $INSTALLPATH/Unity/Editor/Data/Documentation/en/Manual/index.html
... and its API documentation : $INSTALLPATH/Unity/Editor/Data/Documentation/en/ScriptReference/index.html
Why do you not provide your framework documentation ?
I'm quite sure 90% of Unity users uses MSDN website when working on their games.
But think about it; That's like reading MS Word's help when using LibreOffice right ?

So you can find documentation of classes or methods that are not available in unity, especially when integrating other c# library, external to unity.
I found myself unable to use the namespace "System.Threading.Tasks", System.Drawing.Image or also all LINQ-relative syntax that are not available also.

What can we know ?

So, "Internet" says Unity runs a modified Mono 2.6, but from my own very very old post here :
I tried to get dynamically the Mono version, and that is a mess :

#$INSTALLPATH\Unity\Editor\Data\Mono\bin\mono.exe" -V
>Mono JIT compiler version 2.0 (Visual Studio built mono)
>Copyright (C) 2002-2010 Novell, Inc and Contributors.
>TLS: normal
>GC: Included Boehm (with typed GC)
>SIGSEGV: normal Notification: Thread + polling
>Architecture: x86
>Disabled: none

To be more precise :

#$INSTALLPATH\Unity\Editor\Data\Mono\bin>monop2 --runtime-version mono.exe
>runtime version: 2.0.50727.1433

In script you can also :

//you will need "using System.Reflection;" in your file header
System.Type type = System.Type.GetType("Mono.Runtime");
if (type != null) {
System.Reflection.MethodInfo displayName = type.GetMethod("GetDisplayName", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
if (displayName != null)
    Debug.Log(displayName.Invoke(null, null)); // On Unity5.0 it printed "2.0 (Visual Studio built mono)"

Worse a dedicated "Mono Compatibility page" has disappeared since 4.1.2 : => page not found !
Apparently, the modified version of Mono is open-source, but the github link seems quite frozen to me...
So please, help us at least find the real and correct documentation of our everyday framework !

By the way, taken how things move fast :

I know the biggest feature in Unity is its huge portability, and it was named from that, but maybe we can improve our workflow by following the two main directions of .NET and Mono ?
When you looked at the history of Mono releases  (Yes Mono 2.6 is dated from 2009) and the Microsoft's ones (.NET 4.0 and .NET 4.5 ) there is great features and Unity could benefits from them.
(To follow the equivalent rule between these twos, Let's say Mono 2.6 is equivalent to C# 3.0 (in terms of language features). Mono 2.6.1 started adding .NET 4.0 features).
But what about the "modified version" Unity uses ?
Did it evolves along side of the Editor ?
Maybe I'm wrong, and if this kind of documentation exists, I will be  very thankful to anyone who can link it to me !
But if not, please please provides us something to work with ^^.


How to batch Motionbuilder: FBX SDK to the rescue.

When I suddently discovered that MotionBuilder does not have a batch mode, I fainted, as I consider doing my job is half the time coding batch tools.

As a reminder, the Batch version of a software is the access of this one in command-line; means without interfaces, but more importantly it is also scriptable so you can process infinite auto-tasks management with it.
Maya comes with a mayabatch.exe, and xsi has its xsibatch.exe, but you can just start MotionBuilder.exe with a -console flag, which allow you having an external output, nothing really fancy.
This is a real issue here: How can building a python framework, multi-environment, and keep tools doing full-auto pipeline processes.
Thankful to Autodesk policy, they gave us a solution : FBX SDK.

  • Explanations:

FBX SDK is written in c++, but hopefully Autodesk managed to wrapped it with SWIG to propose a binding python (if the link is dead, try a search with fbx sdk python binding in Area)
The full doc is actually here, but it is the c++ one. Do not worry about it, python equivalent are found easily (remember dir statement).

So, Is this another environement to my framework: FBX ? Not quite.
We are still in standalone python, but we are using a library to PARSE a file format.
As Maya uses .MA as a 3d structure of succession of MEL Commands, and .MB as a binay, FBX provides both ascii and binary, but ascii fbx are very hard to parse.
FBX SDK help you to read, modify and save any file of FBX, but require only python, ANY python installed on your computer.
For example, I use FBX SDK to open, read, and manage a fbx file, running into a mayabatch.exe (and its mayapy python).
You can also used FBX SDK into MotionBuilder UI, but that is REALLY the snake eating its own tail !

  • Several snippets:

Here I share with you several usefull snippets:

def getHandle(_FilePath):
  import PyFBX
  import PyFBX.fbx

  lSdkManager = PyFBX.fbx.KFbxSdkManager.Create()
  ios = PyFBX.fbx.KFbxIOSettings.Create(lSdkManager, PyFBX.fbx.IOSROOT)
  lImporter = PyFBX.fbx.KFbxImporter.Create(lSdkManager, "")
  lImporter.Initialize(_FilePath, -1, lSdkManager.GetIOSettings())
  MobuFileHandle = PyFBX.fbx.KFbxScene.Create(lSdkManager, "myScene")
  return MobuFileHandle

If you use that to parse a lot of files, be really sure to free the RAM from
.Import here will literally copy the file into the RAM of your computer, and as the reference is still alive, the garbage collector will not free the RAM.
My advice here is to explicitly calling lSdkManager.Destroy() and recreate a fileHandle from scratch every time you switch from a file to another.

def saveAs(_FBXHandle, _FilePath):
  import PyFBX
  import PyFBX.fbx
  import os.path
  lSdkManager = PyFBX.fbx.KFbxSdkManager.Create()
  ios = PyFBX.fbx.KFbxIOSettings.Create(lSdkManager,PyFBX.fbx.IOSROOT)
  lExporter = PyFBX.fbx.KFbxExporter.Create(lSdkManager,"")
  res = lExporter.Export(_FBXHandle)

  if res and os.path.exists(_FilePath):
    print("File was exported succesfully at ="+_FilePath)

Remember how Motionbuilder manage their types of objects in Navigator Models aside, and all objects ordered by types?
Same thing here in FBX, everything is stored by types first, and you have a Method of Scene for everyone:
Finally, notice how most of them are only accessible with an index, GetCharacter, GetControlSetPlug, GetCharacterPose, GetPose , GetMaterial, GetTexture, GetVideo
Here are some snippets for parsing:

def getVideoFiles(_Scene):
  for currentIdx in range(_Scene.GetVideoCount()):
    VideoList.append( _Scene.GetVideo(currentIdx).GetFileName() )
  return VideoList

def getMaterials(_Scene):
  for currentIdx in range(_Scene.GetMaterialCount()):
    MaterialList.append( _Scene.GetMaterial(currentIdx) )
  return MaterialList

def getTextures(_Scene):
  for currentIdx in range(_Scene.GetTextureCount()):
    TextureList.append( _Scene.GetTexture(currentIdx) )
  return TextureList

def getChildren(_Node):
  for currentIdx in range(_Node.GetChildCount()):
    ChildrenList.append( _Node.GetChild(currentIdx) )
  return ChildrenList

So you can easily explore the graph of a top node:

def getAllNodes(_TopNode):
  import PyFBX
  import PyFBX.fbx

  def recurseExplore(currentNode):
    print currentNode.GetTypeName(), currentNode.GetName()

    for i in range(currentNode.GetChildCount()):
      cur = currentNode.GetChild(i)

  return theNodeList
fd = getHandle(r"\\...\Your\Path\FileName.fbx")
test = getAllNodes(fd.GetRootNode())

  • Avoiding traps and shortcuts:

Finally, you can of course look for a specific property.
You have in the doc all the methods for getting rotation or translation in Nodes.
Here is some snippets to get a value of a property by name, for example your own custom ones.

#currentNode= fd.GetRootNode()
value = currentNode.FindProperty(_PropertyName).Get()

But be very careful about not mixing both SDK in your mind!
FBX is NOT Motionbuilder, and experienced python coders in Mobu will find some similarities, but it differs a lot.
For example, forget about .Data member of a node to get its value, but use .Get() method.

Precisely, python in Mobu is called "Open Reality SDK" and is not FBX SDK, but the python package name in mobu, pyfbsdk, can be really confusing (FB prefix comes from FilmBox).
Here are some others examples:

if type(currentNode) == PyFBX.fbx.KFbxNode:
  value = currentNode.Translation.Get()
  print type(value), type(value[0]),value[0]
#<class 'fbx.fbxDouble3'> <type 'float'> 0.0
  value = currentNode.GetPreRotation(0)
  print type(value), value, value[0]
#<class 'fbx.KFbxVector4'> fbx.KFbxVector4(0.000000, 0.000000, 0.000000, 1.000000) 0.0

  • The bright and dark sides

You can open the scenes quickly, automatically.
You can safely open/close a lot of files like this.

I encountered some issues while saving cleaned file, so be sure to increment and not overwrite (as usual of course!)
You cannot blast, cannot plot, etc. ; well basically, you are not in mobu, nor using pyfbsdk module, but you can go very far (edit keys for example)

In my present experience with MotionBuilder, I used FBX SDK to:

- Scan all characters assets to parse a specific PreRotation joint value.
- Scan all scenes to list their content, sync it with asset management system.
- Done some stats about the artists worked, draw dependencies graph and find obsolete assets.


Invisible chars could be a nightmare

... so avoid them at all costs. Show these shy bastards !

The main trick about whitespaces is about not being able to see them, or count them.

Because you could fail an == operator due to these discreet ghosts,
or also badly concatenate paths or batch commands,
please always configure your IDE to show whitespaces and co.

  • Tabs too !

Especially dealing with python, I found very usefull to display an arrow (Eclipse, NotePad++) or a line (Sublime) to easily count the level of indentation.
But it happens sometimes you have to merge foreign code, from others snippets, from internet, from samples in doc of your Maya/MotionBuilder/whatever, and you will have to conform everything.
So let's make a rule of showing every tabs as whitespaces (4) and display whitespaces.

  • my IDE Configuration reminders.
  1. Eclipse: Window > Preferences > General > Editors > Text Editors  "whitespace characters"
  2. Sublime: on file Preferences.sublime-settings
    "draw_white_space": "all",
    "tab_size": 4,
    "translate_tabs_to_spaces": true,
  3. MonoDevelop: Tools>Options: Text Editor>Markers and Rulers "Whitespace Markers"
  • Log it right!

    When displaying a variable, for a quick debug of a value, I prefer to always finish by an equal without spaces like that:

    print("MyVar ="+str(MyVar))

    It's a not nice to read, but displaying like that you will have a real certitude about the start of the value. Just after the marker "=". You cannot be more sure.

  • End of the line...

At last, I do not show EndOfTheLine carret. Because they are blurrying the view, especially from braces opening.
And I never encounter a case where it is helpful to display. Please sure if you have !


Tagged as: , No Comments

Relasing on iOS App Store

After releasing on Android, this time for my second game I decided to test Apple iOS system and realising also on the App Store.
My reasons were :
1) Great opportunity to learn about this OS, and on all this MAC-world I knew nothing about.
2) A lots of people are using theirs devices, so let's see if they are interested in my games.

Well, if I put aside the iPhone/iPad devices to have (mandatory to real debugging), this cost me a lot!
After rented an 2007 white macbook, I discovered that I need a very recent XCode (4.5) to target latest iOS6, so... I had to buy myself a recent macbook.
iOS6 ==needs==> XCode4.5 ==needs==> Lion ==needs==> recent MAC (see this webpage for compatibility)

But the nightmare was just started. As I already created my encryption keys in my old mac, and synchronised with my Apple Developer account...
That was a mess: it was bloody, it was insane... and if you want a step by step tutorial on how I finally managed to sign my App: I can't !
Honestly I really do not know how, after trying everything with that KeyHolder application, How I was successfull. It was just pure random...

I think I'm cursed, because I always have encryption-key issues !
Joke apart, this really freezed me about doing free trial versions, or with micro-payment management...
because that is as much keys to manage !

Filed under: Dev-illogics No Comments

Failing @publishing on Android PlayStore: Signing package with correct encryption !

I record here my painful experience as releasing my second game on Google Android Market: the "Play Store".

I find that I signed my apk with a key with the latest JAVA 1.7 keytool, that used as crypto algorithm "SHA256withRSA"
I found this algorithm is not supported by Android Publishing, and provoke an error : "Package file was not signed correctly" when installed (so AFTER being purchased!)
The very epic fail is that the apk was authorized and google let me release on the market a deficient application !

In the rush, I uninstalled JDK 1.7, rolling back to 1.6, delete my key from my current keystore, and re-create one (same name) with "SHA1withDSA" encryption...
When I uploaded the new release, well encrypted this time, I get this FANTASTIC error just after the upload process in my dev web-page: "The apk must be signed with the same certificates as the previous version."
Ok then... so I can NOT fix my release because of my first wrong encryption (caused by a better default algorithm remember). Wonderfull.

After several mails unanswered and some forum topics , I decided to unpublished my whole game. And create a new one, same name, same description but with a good SHA1-encrypted first apk upload.
I hope my bad experience will be useful for someone...

Lesson learned ? Not use latest jdk Well understand all releasing/publishing processes and do not let any commands or steps as default value.
If you do not understand an argument, an option in Unity3d (which create your key user-frendly but with default values, do NOT ignore it, and give you TIME to read about it. Painful BUT Safe.

Little step by step processes:
1°) Install JDK 1.6, and to not forget to add this environment variables:
JAVA_HOME C:\Program Files\Java\jdk1.6.0_26
Path C:\Program Files\Java\jdk1.6.0_26\bin
2°) In CommandLine interpreter, type:
keytool -genkey -alias TheNameYouWant -keystore
3°) Verify your key like that:
keytool -v -list -keystore "TheNameYouWantPrivateKey.keystore"
4°) Check apk signature:
jarsigner -verify -certs -verbose D:\The\Path\To\Your\Application\MyAwesomeGame.apk


Bloody Typing (my second smartphone game) is realeased !

Bloody Typing

My second game is realeased on both Apple and Android Market !

It is a typing game: you kill ennemies when you type their "names".
It is fun, it is arcade, and it WILL improve your typing skills !

Apple iOS App Store link    &     Android Play Store link
It is done in Unity3d, in c#.

It contains:

MODE STORY: unlock one by one all words categories to unlock next levels.
4 environments are currently infested by evil vampires !
Words categories are:
Graveyard: "Color","Sport","Common"
Misty Forest: "Animal","Stars","Plants"
Ruined Castle: "Body", "Bitter biters", "Phobia"
Mad Lab: "Science","Dino","Extinct species", "Medical"

Each story levels end by a BOSS, that can be only killed by a famous quote!
MODE ARCADE: Scoring challenge to type faster, making big scores on longer words.
TIMED CHALLENGES: Beat your score on a fixed duration, perfect mode for public transports!

To have tested my game myself, I can assure you it will really help you to type faster.
It helps memorize the keyboard layout, and on top of that you also learn some vocabulary !

Three difficulty modes assures that casuals could access every corner of the game,
by the way hard difficulty and scoring let the game "Easy to learn, Hard to master".

3 Virtual keyboard layouts are available right now: QWERTY, DVORAK, AZERTY
You also had the option to hide the keyboard, for a very challenging blind game !
Learning or improving how to type with fun ! Write enemies names to kill them.


Acronym is EVIL

I really enjoy all my experience in python-coding because I find it very readable and transparent.
Yes we're math guys, but honestly 80% of our time is dedicated to one single process:
BECAME UNDERSTANDABLE by theses f***ing stupid machines.

Python is really great for that, re-usability, factoring stuff,
building framework, and all your applications can be read like a book.
BUT, and I mean it, all theses efforts are useless if we are fuzzy, imprecise or the worst of it: concise.
I'm pretty sure that nobody will advice to call a variable "a, b , toto", but better to stick to "currentRootJoint", right ?

So why I see sooooo many acronyms along the internet snippets ? Around templates or also in python mechanics ? (Cf my APyTA post on python referencing)
Python does not recommend using import *, to avoid collapsing names.
We're writing to machines, who only recognize keywords, so please do NOT complicates things and shorcut your code.

Yes, "pmc"  is shorter that "pymel.modeling.core" but do you well remember it ? One year later ?
How can you be sure that you will not require an external module, in a distant future, who will have pmc as acronyms  too?
You have "dof" everywhere for your "degree of freedom" in your character-rigging tollkit,
and six month later, you are dealing with rendering and "depth of field", so.... "dof" also ? Is this readable really ?
Same thing in c# and Unity3d, for Random for example (Do you mean UnityEngine.Random  or  System.Random ?)

Therefore, I strictly forbid any acronyms in my personal naming convention. And I mean it.
So yes, my code is wider. But I was taught to not make functions too high, not too large !
We code now on the same workstation that infographists, so 24inches is not an issue at all !

Long import, long call of function (I always write pymel.core.modeling.polyCube() , but like that I am precise. I know where I come from (notion of namespace like in c#).
And when I am dealing with my own framework (which is multi-contextual, and manage several workflows, as Mobu;Maya, etc., with an external asset manager), I really need this "full package path".

On top of that, when you are tinying your names (function, var, import) you just keeping your knowledge for yourself.
(And for the yourself of 'right now'). That's selfish.
A future reader, coming from a non-CGI world, would most probably do not understand you. From the "not so different math-world" there is many ways of splitting our point of view (like the Y-axis definition)...
I know that I 'm quite alone on this fight, and my coding style appears weird or preposterous, and are not like all others API, but I kept this philosophy which suits me.


Hanoi Tower 1.1

A gamer brought my first game on Android, but unfortunately he didn't like it.
He played the hardest difficulty, finish it, and claims for a payback (which I give him).

Quite disappointed, I decided to create an update, a 1.1 version, with a maximum of 10 discs !
I upgrade some of the graphics, doing some reflections shaders on some discs.

So, as a lesson, I will keep in mind: "Do NOT forget hardcore gamers, although they are not our primary target, their anger DO damage".

The video presentation on youtube !


Epic Fail ?

Well no more customers for my first little game.

I just waited one month : 4 first clients, 4 friends adding comments, and no more.
And their comments never shows off...

Damn, why it is so easy to publish a game and so hard to comment it ? Does Google needs to read them for some reasons ?

I was so excited to see 4 people over the world playing my game (probabily found in top news for a couple of seconds)...

... and then, no more way to find the game on the market (ecept knowing exactly its name). Boring.


There is always a first step…

And mine is today. Hum... tonight.

I always wanted to write stories, share pictures I had in my head. I do not know how to draw, but I know (quite a little) how to be understood by machines.
So, here I am, in my last PhD year, doing my first videogame, from scrath to the very end, and publishing it. In android market !

Yes, when i learnt infography, I wanted to write the stor of Final Fantasy 24 in 2024. Now I don't.But I still love rpgs^^.
First things first, I made a quick puzzle game. No lot code, no lot assets, no lot game modes.
It was so looooong to finish ! Yes I have also a job and a thesis to make and write, but this adventure is started from.... 6 months almost.

Well, it is done. And this first step is the start of my devblog, my new site dedicated do game desining, and... a whole new life !