Log in or register to post comments

Initialize video texture with script on button

August 27, 2013 - 5:16am #1

Hi.

I'm using the video texture code from the tutorial on this site and I've got 7 videos on an AR console. The way I've coded it is so that all the video planes are in the same place but if a button is pressed it becomes active in the scene, and can be played. The issue I'm having is that if a video isn't paused when another is selected then it keeps playing, so I'm trying to reference the VideoPlaybackBehaviour script and initialize the video if any other button is pressed. This way the audio won't double up and if the user is watching a video and selects another, and then returns, then the video will have rewound and be ready to play again. This is part of my poor attempt at referencing the video script on the video plane. Even the first 'var vidScript : VideoPlaybackBehaviour' isn't working and I've followed the unity component/script reference tutorial to the letter. Help!

R

 

 

#pragma strict

 

private var ray: Ray;

private var hit : RaycastHit;

private var vid1 : GameObject;

private var vid2 : GameObject;

private var vid3 : GameObject;

private var vid4 : GameObject;

private var vid5 : GameObject;

private var vid6 : GameObject;

private var vid7 : GameObject;

 

public var otherGameObject : GameObject;

 

function Start () {

vid1 = GameObject.Find("Bottom right/Videos Panel/Vid1");

vid2 = GameObject.Find("Bottom right/Videos Panel/Vid2");

vid3 = GameObject.Find("Bottom right/Videos Panel/Vid3");

vid4 = GameObject.Find("Bottom right/Videos Panel/Vid4");

vid5 = GameObject.Find("Bottom right/Videos Panel/Vid5");

vid6 = GameObject.Find("Bottom right/Videos Panel/Vid6");

vid7 = GameObject.Find("Bottom right/Videos Panel/Vid7");

 

vid1.SetActive(false);

vid2.SetActive(false);

vid3.SetActive(false);

vid4.SetActive(false);

vid5.SetActive(false);

vid6.SetActive(false);

vid7.SetActive(false);

 

var vidScript : VideoPlaybackBehaviour;

vidScript = GetComponent(VideoPlaybackBehaviour);

 

}

 

function Update () {

 

if(Input.GetMouseButtonDown(0)){

ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if(Physics.Raycast(ray, hit)){

 

if(hit.transform.name == "Budget"){

vid1.SetActive(true);

vid2.SetActive(false);

vid2.vidScript.mVideoPlayer.Init();

vid3.SetActive(false);

vid3.vidScript.mVideoPlayer.Init();

vid4.SetActive(false);

vid4.vidScript.mVideoPlayer.Init();

vid5.SetActive(false);

vid5.vidScript.mVideoPlayer.Init();

vid6.SetActive(false);

vid6.vidScript.mVideoPlayer.Init();

vid7.SetActive(false);

vid7.vidScript.mVideoPlayer.Init();

}

 
Log in or register to post comments