Skip to content

Instantly share code, notes, and snippets.

@gashtio
Created December 18, 2012 10:17
Show Gist options
  • Save gashtio/4326870 to your computer and use it in GitHub Desktop.
Save gashtio/4326870 to your computer and use it in GitHub Desktop.
Binding JavaScript manually in Unity3D using Coherent UI
public class ManualBinding : MonoBehaviour {
private CoherentUIView m_View;
// Use this for initialization
void Start () {
m_View = GetComponent<CoherentUIView>();
m_View.Listener.ReadyForBindings += HandleReadyForBindings;
}
void HandleReadyForBindings (int frameId, string path, bool isMainFrame) {
if (isMainFrame) {
// bind ApplyOptions to "ApplyOptions" in JavaScript
m_View.View.BindCall("ApplyOptions", (Action<GameOptions>)this.ApplyOptions);
}
}
public void ApplyOptions(GameOptions options) {
// Do something with options
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment