Hi,
I have a plane with a video texture. I want to Play() this from a button in the GUI.
I have found the GameObject but I do not know which component to Get.
I get the Renderer but every option I try on this has not worked.
Been working on this one a while without any success.
thanks for any help
Maybe this works.
(MovieTexture)mov = (MovieTexture)gameObject.renderer.material.mainTexture;
if(mov != null) mov.Play();
Thanks Marc - works perfectly.
for anyone else here is my code:
private GameObject myGameObject;
private Renderer myRender;
private MovieTexture myTexture;
void Start () {
myGameObject = GameObject.Find("VideoPlane");
myRender = (Renderer) myGameObject.GetComponent(typeof(Renderer));
myTexture = (MovieTexture) myRender.material.mainTexture;
}
public void OnGUI() {
if(GUI.Button(new Rect(210,40,100,160), "play video"))
{
if(myTexture != null) myTexture.Play();
else print(myRender.ToString() + " " + myGameObject.ToString() + " texture not found");
}
thanks again Marc