Syntactic sugar for Unity3D binding

by Nick December. 18, 12 0 Comment

Recently, we’ve updated the Unity3D version of our product. Along with various fixes and improvements, we’ve added a feature that allows you to bind JavaScript methods even easier than before. The feature is called “Automatic binding” and it was suggested by one of our beta testers (thanks, Tyler!).

Using the current pattern, you have to wait until Coherent UI fires the ReadyForBindings event, and register your handlers. That would look something like this:

The essence of the new feature is decorating the method in .Net that you want to bind with an attribute, specifying the name of the corresponding JavaScript function. Using the attribute simplifies the code above to the following:

Easy, right? The second argument of the attribute defines whether the JavaScript event should be treated as single or multicast. You can check out the binding sample in our new version, along with detailed explanation in the Coherent UI guide for Unity3D.

We’re always striving to improve our product, so if you have an idea for a cool feature don’t hesitate and drop us a line :).


Follow Nick on Twitter: @Nikxio

Social Shares

Related Articles

Leave a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.