Created
February 20, 2013 08:53
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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