using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class BigVideoManager : MonoBehaviour { public GameObject audioGray; public GameObject audioColor; public GameObject videoGray; public GameObject videoColor; public TextMesh titleName; public CustomPeer cp; public MeshRenderer mr; public GameObject isVideoGM; public GameObject isAudioGM; public void init() { cp.isBig = true; cp.bigView = this.gameObject; CustomRTC.Instance.list.initList(CustomRTC.Instance.cpl); cp.onChangeTexture += onChangeTexture; cp.onChangeInfo += onChangeInfo; mr.material.mainTexture = cp.tex; if (cp.cIdV != null && cp.cIdV != ""&& cp.isVideo) isVideoGM.SetActive(false); else { mr.material.mainTexture = CustomRTC.Instance.t2fang; isVideoGM.SetActive(true); } if (cp.cIdA != null && cp.cIdA != "" && cp.isAudio) isAudioGM.SetActive(false); else isAudioGM.SetActive(true); titleName.text = "用户名:" + cp.name; if (cp.cIdV == "") { Debug.Log("A"); videoGray.SetActive(true); videoColor.SetActive(false); } else { Debug.Log("A1"); videoGray.SetActive(false); videoColor.SetActive(true); } if (cp.cIdA == "") { Debug.Log("B"); audioGray.SetActive(true); audioColor.SetActive(false); } else { Debug.Log("B1"); audioGray.SetActive(false); audioColor.SetActive(true); } } public void onChangeCloseInfo() { Debug.Log("onChangeInfo。。。。"); if (cp.cIdV == "") { if (cp.isVideo) { isVideoGM.SetActive(false); } else { isVideoGM.SetActive(true); } mr.material.mainTexture = CustomRTC.Instance.t2fang; Debug.Log("A11"); videoGray.SetActive(true); videoColor.SetActive(false); } if(cp.cIdA=="") { if (cp.isAudio) { isAudioGM.SetActive(false); } else { isAudioGM.SetActive(true); } Debug.Log("B11"); audioGray.SetActive(true); audioColor.SetActive(false); } } private void onChangeTexture() { if (cp.isVideo) { mr.material.mainTexture = cp.tex; } } private void onChangeInfo(string type, string id) { Debug.Log("onChangeInfo。。。。"); if (type == "video") { if (cp.isVideo) { isVideoGM.SetActive(false); } else { closeVideo(); //isVideoGM.SetActive(true); } videoGray.SetActive(false); videoColor.SetActive(true); Debug.Log("A111"); } else { if (cp.isAudio) { isAudioGM.SetActive(false); } else { closeAudio(); //isAudioGM.SetActive(true); } Debug.Log("B111"); audioGray.SetActive(false); audioColor.SetActive(true); } } private void OnDestroy() { cp.onChangeTexture -= onChangeTexture; cp.onChangeInfo -= onChangeInfo; } public void close() { cp.isBig = false; CustomRTC.Instance.list.initList(CustomRTC.Instance.cpl); Destroy(this.gameObject); } public void closeRemove() { cp.isBig = false; // CustomRTC.Instance.list.initList(CustomRTC.Instance.cpl); Destroy(this.gameObject); } public void chooseVideo() { if (isVideoGM.activeSelf) { openVideo(); } else { closeVideo(); } } public void chooseAudio() { if (isAudioGM.activeSelf) { openAudio(); } else { closeAudio(); } } public void openVideo() { if (cp.cIdV != "") { cp.isVideo = true; SCRtcFactory.Instance.mSCRtcHandle.openRev(cp.cIdV); mr.material.mainTexture = cp.tex; // if (cidV != "") // SCRtcFactory.Instance.mSCRtcHandle.openRev(cidV); // Debug.Log("openVideo2" + cidV); isVideoGM.SetActive(false); if (CustomRTC.Instance.bigNameID == "") { CustomRTC.Instance.showNextTexture(); } } } public void closeVideo() { if (cp.cIdV != "") { cp.isVideo = false; SCRtcFactory.Instance.mSCRtcHandle.closeRev(cp.cIdV); Texture2D oVideo = cp.tex; mr.material.mainTexture = CustomRTC.Instance.t2fang; isVideoGM.SetActive(true); if (CustomRTC.Instance.bigNameID == cp.peerId) { CustomRTC.Instance.showNextTexture(); } } } public void openAudio() { if (cp.cIdA != "") { cp.isAudio = true; SCRtcFactory.Instance.mSCRtcHandle.openRev(cp.cIdA); isAudioGM.SetActive(false); } } public void closeAudio() { if (cp.cIdA != "") { cp.isAudio = false; SCRtcFactory.Instance.mSCRtcHandle.closeRev(cp.cIdA); isAudioGM.SetActive(true); } } }