Skip to content

Instantly share code, notes, and snippets.

@dimitarcl
Last active December 16, 2015 14:59
Show Gist options
  • Save dimitarcl/5452402 to your computer and use it in GitHub Desktop.
Save dimitarcl/5452402 to your computer and use it in GitHub Desktop.
Coherent UI 1.2.1
using Coherent.UI;
using Coherent.UI.Binding;
namespace MyGame
{
class Options
{
public bool SetWindowSize(int width, int height);
}
class MyGame
{
Options m_Options;
BoundObject GetOptionsForUI()
{
// wrap m_Options so its methods are exported
return BoundObject.BindMethods(m_Options);
}
void OnViewReady(View view)
{
view.BindCall("getOptions", this.GetOptionsForUI);
}
}
}
engine.call('getOptions')
.then(function (options) {
return options.SetWindowSize(1920, 1280);
})
.then(function (result) {
// chaining of promises works so
// result is the boolean returned by m_Options.SetWindowSize
if (result) {
console.log('resolution changed')
} else {
console.error('could not change resolution');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment