123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using ShadowStudio.Mgr;
- using ShadowStudio.Model;
- using ShadowStudio.UI;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using Vuforia;
- using XRTool.Util;
- using XRTool.WorldUI;
- public class ItemUserView : MonoBehaviour
- {
- public Peer _peer;
- public MeshRenderer videoBG;
- public Text nametext;
- public XRIcon touxiang;
- public Button bigBtn;
- // Start is called before the first frame update
- void Start()
- {
- bigBtn.onClick.AddListener(OnClickBigBtn);
- }
- private void OnClickBigBtn()
- {
- if (ShowViewMgr.Instance)
- {
- PlayerViewComponent.CreateViewComponent(this._peer.PeerId, ShowViewMgr.Instance.Target);
- }
- }
- private void Update()
- {
- checkPeer();
- StateUpdata();
- }
- void checkPeer()
- {
- if (cPeer == null && _peer != null)
- {
- cPeer = AgoraRTCManager.Instance.GetCustomPeer(_peer.PeerId);
- _peer.AgoraCustomPeer = cPeer;
- }
- }
- void StateUpdata()
- {
- if (cPeer == null)
- return;
- // Debug.Log(cPeer.peerId + " " + cPeer.isVideo + cPeer.isOpenVideo + cPeer.isAudio + cPeer.isOpenAduio);
- if (cPeer.isVideo)
- {
- if (cPeer.isOpenVideo)
- {
- openVideo.SetActive(false);
- closeVideo.SetActive(false);
- pauseVideo.SetActive(true);
- }
- else
- {
- openVideo.SetActive(false);
- closeVideo.SetActive(true);
- pauseVideo.SetActive(false);
-
-
- }
- }
- else
- {
- openVideo.SetActive(true);
- closeVideo.SetActive(false);
- pauseVideo.SetActive(false);
- }
- if (cPeer.isAudio)
- {
- if (cPeer.isOpenAduio)
- {
- openAudio.SetActive(false);
- closeAudio.SetActive(false);
- pauseAudio.SetActive(true);
- }
- else
- {
- openAudio.SetActive(false);
- closeAudio.SetActive(true);
- pauseAudio.SetActive(false);
-
- }
- }
- else
- {
- openAudio.SetActive(true);
- closeAudio.SetActive(false);
- pauseAudio.SetActive(false);
- }
- }
- AgoraCustomPeer cPeer;
- public void Init(Peer peer)
- {
- Debug.Log("123213Init213213"+ peer.Avatar);
- _peer = peer;
- nametext.text = peer.NickName;
- textMic.text = "0.02";
- VolumnGo.SetActive(false);
- if (!string.IsNullOrEmpty(peer.Avatar))
- {
- for (int i = 0; i < CommonMethod.UserAvatarsList.Count; i++)
- {
- if (peer.Avatar == CommonMethod.UserAvatarsList[i].Url)
- {
- string path = "Avatar/" + CommonMethod.UserAvatarsList[i].Id + "Avatar";
- touxiang.icon = Resources.Load(path) as Texture2D;
- touxiang.AutoSetSprite();
- }
- }
- }
- if (_peer.IsSlef)
- {
- nametext.text = "<color=yellow>" + peer.NickName + "</color>";
- openAudio.GetComponent<UnityEngine.UI.Image>().color = new Color(255, 0, 0, 255);
- openVideo.GetComponent<UnityEngine.UI.Image>().color = new Color(255, 0, 0, 255);
- Invoke("checkAudio", 0.5f);
- // Invoke("checkVideo", 1f);
- }
- }
-
- public GameObject openAudio;
- public GameObject closeAudio;
- public GameObject VolumnGo;
-
- public float volume = 0.2f;
- public Text textMic;
- public void addMic()
- {
- volume += 0.1f;
- }
- public void redMic()
- {
- volume -= 0.1f;
-
- }
-
- public GameObject pauseCerAudio;
- public GameObject pauseCerVideo;
- public GameObject pauseAudio;
- public GameObject pauseVideo;
- public GameObject openVideo;
- public GameObject closeVideo;
- public void openMic()
- {
- if (_peer.IsSlef)
- {
- AgoraRTCManager.Instance.MuteLocalAudioStream(true);
- }
- else
- {
- AgoraRTCManager.Instance.MuteRemoteAudioStream(cPeer.peerId, true);
- }
- }
- public void closeMic()
- {
- if (_peer.IsSlef)
- {
- AgoraRTCManager.Instance.MuteLocalAudioStream(false);
- }
- else
- {
- AgoraRTCManager.Instance.MuteRemoteAudioStream(cPeer.peerId, false);
- }
- }
- public void OpenVideo()
- {
- if (_peer.IsSlef)
- {
- AgoraRTCManager.Instance.MuteLocalVideoStream(true);
- }
- else
- {
- AgoraRTCManager.Instance.MuteRemoteVideoStream(cPeer.peerId, true);
- }
- }
- public void CloseVideo()
- {
- if (_peer.IsSlef)
- {
- AgoraRTCManager.Instance.MuteLocalVideoStream(false);
- }
- else
- {
- AgoraRTCManager.Instance.MuteRemoteVideoStream(cPeer.peerId, false);
- }
- }
- }
|