以下代码是在IOS设备上播放视频文件
[SerializeField] private RawImage _movieImage;
private bool _isPlayingIntro = false;
void Start () {
#if UNITY_STANDALONE_OSX || UNITY_EDITOR
_movieImage.gameObject.SetActive (true);
var texture = (MovieTexture)_movieImage.mainTexture;
texture.Play ();
_isPlayingIntro = true;
#else
Handheld.PlayFullScreenMovie ("Intro.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
_isPlayingIntro = true;
#endif
}
void Update () {
#if UNITY_STANDALONE_OSX || UNITY_EDITOR
if (_isPlayingIntro && Input.GetMouseButtonDown (0)) {
var texture = (MovieTexture)_movieImage.mainTexture;
texture.Stop ();
_movieImage.gameObject.SetActive (false);
_isPlayingIntro = false;
}else {
if (Input.GetKeyDown (KeyCode.Escape)) {
Application.Quit ();
}
}
#else
if (_isPlayingIntro && Input.GetMouseButtonDown (0)) {
_isPlayingIntro = false;
}
if (Input.GetKeyDown(KeyCode.Escape)) {
Application.Quit();
}
#endif
}