Skip to content

Instantly share code, notes, and snippets.

@gashtio
Created February 20, 2013 08:53
Show Gist options
  • Save gashtio/4994075 to your computer and use it in GitHub Desktop.
Save gashtio/4994075 to your computer and use it in GitHub Desktop.
A helper script that adds a handler for the "OpenDoor" message in the Coherent UI View Listener, received from JavaScript.
using UnityEngine;
using System.Collections;
public class MinigameDoorOpener : 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)
{
m_View.View.BindCall("OpenDoor", (System.Action)this.OpenDoor);
}
}
void OpenDoor()
{
GameObject audioSource = GameObject.Find("interiorDoorSlidingMinigame/AudioSource");
GameObject slidingDoor = GameObject.Find("interiorDoorSlidingMinigame/slidingDoor");
string action = "OnPlay";
//string action = "OnPlayReverse";
audioSource.SendMessage(action);
slidingDoor.SendMessage(action);
}
// Update is called once per frame
void Update () {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment