Is posible add a MovieTexture as a varible and play it using lua?
Is posible add a MovieTexture as a varible and play it using lua?
Ii wonder if it is possible to play a movie texture when the npc response in the dialog?
Re: Is posible add a MovieTexture as a varible and play it using lua?
Sure. Write a C# method to play the movie texture, and then register it with Lua. For example:
In your dialogue entry node, put something like this in the Script field:
Or just add a script to the Dialogue Manager that has an OnConversationLine() method, and play the movie in this method.
Let me know if you'd like more details on any of these methods.
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();
}
}
- Script: PlayMovie(3)
Or just add a script to the Dialogue Manager that has an OnConversationLine() method, and play the movie in this method.
Let me know if you'd like more details on any of these methods.