Mina Fawzy
Mina Fawzy

Reputation: 21452

Unity - how to add video to unity

I need to put video inside plane object

I follow tutorial on how you do that ,

1- Create new material (the video inside material ).

2- attach material to plane object

3- add script as gameController

  using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour {

      public MovieTexture movTexture;
    // Use this for initialization
    void Start () {

        GetComponent<Renderer>().material.mainTexture= movTexture;
        movTexture.Play ();
    }

    // Update is called once per frame
    void Update () {


    }
}

but it give me error

Assets/Scripts/GameController.cs(9,63): error CS1061: Type `UnityEngine.Texture' does not contain a definition for `Play' and no extension method `Play' of type `UnityEngine.Texture' could be found (are you missing a using directive or an assembly reference?)

UPDATED I am using unity 5.1 free , I am trying develop game for Gear VR thats run in android device

Upvotes: 1

Views: 2260

Answers (3)

gilgil28
gilgil28

Reputation: 540

MovieTexture is not supported in Android. Currently there are no simple ways to play videos on android using unity3d other than full screen, unless you buy some assets that make video on textures possible, but no sound.

Upvotes: 1

A.Njuguna
A.Njuguna

Reputation: 81

The assembly reference for adding a video is only integrated with unity pro.

Upvotes: 0

Chris Sinclair
Chris Sinclair

Reputation: 23208

The mainTexture field is of the base Texture class. If you've configured and assigned the material properly, then you can cast it to MovieTexture where you can then call Play():

 ((MovieTexture)GetComponent<Renderer>().material.mainTexture).Play();

Additional information about playing video with MovieTexture can be found in the manual here: http://docs.unity3d.com/Manual/class-MovieTexture.html

Upvotes: 1

Related Questions