ExpandoObject

Author: KeliHlodversson

Description
I've written multiple times on the Unity forum that Unity's Javascript implementation does not support expando objects, i.e. you can not add fields to an object at runtime. The following is valid ECMAScript, but not possible in Unity: This is not entirely correct. Unity's Javascript is based on Boo and when combining ducktyping with Boo's IQuackFu interface, one can in fact implement support for expando objects.

Usage
Add ExpandoObject.js to your project and you will be able to do the following:

Boo
This will also work in Boo (just place the javascript inside Standard Assets to make it compile before the Boo script):

C#
C# Does not support ducktyping, so it will not see the added fields. You can however access the IQuackFu methods directly: