How to play video in unity
1. Create Plane... set Rotation x:90 y:0 z:-180 ; Position : x:0 y:1 z:0 ; Scale :x:1 y:1 z:1 ;
2. Import Example Video file (.mp4, .mov etc) to Project
3. Create Meterial... And set Shader Unlit -> Texture
4. Drag your example video and drop it as select Texture
5. Attach that material to your plane
6. Create C# Script and attach to your Plane.
Script :-
using UnityEngine;
using System.Collections;
public class testMoviePlay : MonoBehaviour {
void Update () {
//(MovieTexture)GetComponent<Renderer>().material.mainTexture).Play();
Renderer r = GetComponent<Renderer>();
MovieTexture movie = (MovieTexture)r.material.mainTexture;
if (movie.isPlaying) {
movie.Pause();
}
else {
movie.Play();
}
}
}
7. Play the Scene...
Enjoy Gaming.......
2. Import Example Video file (.mp4, .mov etc) to Project
3. Create Meterial... And set Shader Unlit -> Texture
4. Drag your example video and drop it as select Texture
5. Attach that material to your plane
6. Create C# Script and attach to your Plane.
Script :-
using UnityEngine;
using System.Collections;
public class testMoviePlay : MonoBehaviour {
void Update () {
//(MovieTexture)GetComponent<Renderer>().material.mainTexture).Play();
Renderer r = GetComponent<Renderer>();
MovieTexture movie = (MovieTexture)r.material.mainTexture;
if (movie.isPlaying) {
movie.Pause();
}
else {
movie.Play();
}
}
}
7. Play the Scene...
Enjoy Gaming.......