I've tried having the playMovie function static but that just gives me errors and I don't know what to do about it.
Here are my two separate scripts:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Commands : MonoBehaviour
{
public GameObject textObj;
public string textInput;
public MovieTexture postbanken;
void Start ()
{
DontDestroyOnLoad(this);
}
void Update ()
{
textInput = textObj.GetComponent().text;
if(Input.GetKeyDown(KeyCode.Return))
{
char quotes = '"';
if(textInput == "play " + quotes.ToString() + "Postbanken" + quotes.ToString())
{
Debug.Log ("Now playing 'Postbanken' ");
Application.LoadLevel("videoPlay");
}
}
}
}
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(AudioSource))]
public class PlayVideo : MonoBehaviour
{
public bool hasStarted;
public bool videoIsPlaying;
public void playMovie (MovieTexture videoFile)
{
this.gameObject.GetComponent().material.mainTexture = videoFile as MovieTexture;
this.gameObject.GetComponent().clip = videoFile.audioClip;
videoFile.Play();
this.gameObject.GetComponent().Play();
videoFile.loop = false;
hasStarted = true;
videoIsPlaying = true;
}
void Update ()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
Application.LoadLevel("CommandLine");
}
if(videoIsPlaying == false && hasStarted == true)
{
Application.LoadLevel("CommandLine");
}
}
}
↧