public void Stop() { if (m_VideoPlayer != null) { m_VideoPlayer.Stop(); m_VideoPlayer.gameObject.SetActive(false); } if (m_OnCancel != null) { m_OnCancel.Invoke(m_VideoPlayer); m_OnCancel = null; } GTWindowManager.Instance.LockNGUI(false); }
private void Awake() { PrepareCompleteEvent += (vp) => { }; videoPlayer = gameObject.GetComponent <VideoPlayer>(); videoPlayer.prepareCompleted += (vp) => PrepareCompleteEvent.Invoke(vp); videoPlayer.prepareCompleted += (vp) => { if (readyToPlay) { Play(); } readyToPlay = false; }; _texture = new Texture2D(0, 0); }
private void VideoPlayer_loopPointReached(VideoPlayer source) { LoopPointReached?.Invoke(source); }
// Update is called once per frame void Update() { if (done == false && (command.type == FMVManager.CommandType.AUDIO || command.type == FMVManager.CommandType.SONG)) { AudioSource audioSource = gameObject.GetComponent <AudioSource>(); if (audioSource && audioSource.clip) { if (audioSource.clip.loadState == AudioDataLoadState.Loaded || audioSource.clip.loadState == AudioDataLoadState.Failed) { if (audioSource.isPlaying == false) { Debug.Log("detected song end " + command.file); EndReached(vp); prepared = true; } } } } if (prepared == false) { return; } if (rp != null) { if (rp.transform.position.z > 9001) { rp.transform.position = new Vector3(0, 0, rp.transform.position.z - Time.deltaTime); } else if (rp.transform.position.z > 9000 && freezeFrame == false) { var r = rp.GetComponent <MeshRenderer>(); var m = r.material; //m.mainTexture = Instantiate(m.mainTexture); m.SetColor("_keyingColor", transparentColor); m.SetFloat("_thresh", threshold); m.SetFloat("_slope", slope); rp.transform.position = new Vector3(0, 0, command.z); } float scale = Camera.main.aspect / 2.0f; if (scale > 1.0f) { scale = 1.0f; } rp.transform.localScale = new Vector3(scale * 2.0f, 1, scale); if (done && vp != null) { var r = rp.GetComponent <MeshRenderer>(); var m = r.material; var rt = m.mainTexture as RenderTexture; RenderTexture currentActiveRT = RenderTexture.active; RenderTexture.active = rt; Texture2D tex = new Texture2D(rt.width, rt.height); tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0, false); tex.Apply(); RenderTexture.active = currentActiveRT; Destroy(m.mainTexture); m.mainTexture = tex; Destroy(vp); Destroy(this.GetComponent <AudioSource>()); vp = null; m.SetColor("_keyingColor", transparentColor); m.SetFloat("_thresh", threshold); m.SetFloat("_slope", slope); rp.transform.position = new Vector3(0, 0, command.z); } } if (fadeInTime > 0) { vp.targetCameraAlpha += fadeInSpeed * Time.deltaTime; fadeInTime -= Time.deltaTime; if (fadeInTime <= 0) { vp.targetCameraAlpha = 1; if (freezeFrame == false) { vp.Play(); } else { EndReached(vp); } } } else if (fadingOut) { if (fadeOutTime > 0) { vp.targetCameraAlpha -= fadeOutSpeed * Time.deltaTime; fadeOutTime -= Time.deltaTime; } else if (fadeOutSpeed > 0) { vp.targetCameraAlpha = 0; done = true; if (fadeOutFinished != null) { fadeOutFinished.Invoke(vp); fadeOutFinished = null; } Destroy(this.gameObject, 15); } else if (done == false) { done = true; if (fadeOutFinished != null) { fadeOutFinished.Invoke(vp); fadeOutFinished = null; } //Destroy(this.gameObject);//only destroy when there is a video to replace it? } } /*else if (vp.targetCameraAlpha != 1) * { * vp.targetCameraAlpha = 1; * vp.Play(); * }*/ }