Is posible add a MovieTexture as a varible and play it using lua?
Posted: Thu Apr 21, 2016 9:20 pm
Ii wonder if it is possible to play a movie texture when the npc response in the dialog?
Support and discussion forum for Pixel Crushers products
https://www.pixelcrushers.com:443/phpbb/
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class LuaMoviePlayer : MonoBehaviour {
public MovieTexture[] movieTextures; // Array of movies.
private MovieTexture currentMovieTexture;
void OnEnable() {
Lua.RegisterFunction("PlayMovie", this, SymbolExtensions.GetMethodInfo(() => PlayMovie((int) 0)));
}
void OnDisable() {
Lua.UnregisterFunction("PlayMovie");
}
public void PlayMovie(int i) {
currentMovieTexture = movieTextures[i];
GetComponent<Renderer>().material.mainTexture = currentMovieTexture;
currentMovieTexture.Play();
Invoke("StopMovie", 1); // Stop playing after 1 second.
}
public void StopMovie() {
currentMovieTexture.Stop();
}
}