123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- 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);
- }
- }
- }
|