Billboard video rendering - SetActive
I put movies in each billboard plane and would like to play it one by one in the order. I am giving the direction to the audience when to make a trigger (using leap motion, hovering their hands over the leap motion device).
This code is not working well. It plays the first billboard video, but does not go to bill2 (second billboard). Below is the script attached to handcontroller of leap motion (which is the player character in conventional games, I believe).
using UnityEngine; using System.Collections;
public class NextScene : MonoBehaviour {
public GameObject bill1;
public GameObject bill2;
public GameObject bill3;
public GameObject bill4;
public GameObject bill5;
// Use this for initialization
void Start () {
Debug.Log ("start");
bill1.SetActive(true);
bill2.SetActive(false);
bill3.SetActive(false);
bill4.SetActive(false);
bill5.SetActive(false);
}
// Update is called once per frame
void OnTriggerEnter (Collider other)
{
if (bill1.activeInHierarchy == true)
{
Debug.Log ("enter");
bill1.SetActive(false);
bill2.SetActive(true);
}
else if (bill2.activeInHierarchy == true)
{
Debug.Log ("enter2");
bill2.SetActive(false);
bill3.SetActive(true);
}
else if (bill3.activeInHierarchy == true)
{
Debug.Log ("enter3");
bill3.SetActive(false);
bill4.SetActive(true);
}
else if (bill4.activeInHierarchy == true)
{
Debug.Log ("enter4");
bill4.SetActive(false);
bill5.SetActive(true);
}
}
}
Below is the code for each billboard. I would truly appreciate the advice! (audio source was not importing from the inspector, so I just commented them out for now).
using UnityEngine; using System.Collections;
public class PlayBillboard : MonoBehaviour {
//public AudioSource source;
public MovieTexture movieOne;
/*
public void Start()
{
source = GetComponent<AudioSource> ();
} */
//if (Input.GetKeyDown (KeyCode.Space)) {
void OnTriggerEnter(Collider other)
//{if (!movieOne.isPlaying)
{
Debug.Log ("play");
movieOne.Play ();
//source.Play ();
}
}