From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/Video/XVideoMgr.cs | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Client/Assets/Scripts/Video/XVideoMgr.cs (limited to 'Client/Assets/Scripts/Video/XVideoMgr.cs') diff --git a/Client/Assets/Scripts/Video/XVideoMgr.cs b/Client/Assets/Scripts/Video/XVideoMgr.cs new file mode 100644 index 00000000..a8a5f0cf --- /dev/null +++ b/Client/Assets/Scripts/Video/XVideoMgr.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using XUtliPoolLib; +using System.Collections; +using System; + +public class XVideoMgr : MonoBehaviour, IXVideo +{ +#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + public MovieTexture Movie; +#endif + + private XVideo _video = null; + private AudioSource _audio = null; + + public bool isPlaying { get { return _video != null && _video.isPlaying; } } + + void Start() + { +#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + GameObject root = GameObject.Find(@"XGamePoint"); + + _video = root.AddComponent(); + _audio = root.AddComponent(); +#endif + } + + public void Play(bool loop = false) + { +#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + { + _video.Play(Movie, _audio, loop); + } +#else + { + Handheld.PlayFullScreenMovie("CG.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput, FullScreenMovieScalingMode.AspectFit); + } +#endif + } +#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + void Update() + { + if (_video.isPlaying && Input.GetMouseButtonUp(0)) + { + _video.Stop(); + } + } +#endif + public void Stop() + { +#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + { + if (_video != null) _video.Stop(); + } +#endif + } + + public bool Deprecated + { + get; + set; + } +} -- cgit v1.1-26-g67d0