RTCRoomMain.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Blue;
  2. using TMPro;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class RTCRoomMain : AbstractController
  6. {
  7. [SerializeField] private TextMeshProUGUI mRoomName_Text; // 房间名
  8. [SerializeField] private TextMeshProUGUI mRoomID_Text; // 房间ID
  9. [SerializeField] private TextMeshProUGUI mRoomPeopleCount_Text; // 房间人数
  10. [SerializeField] private Button mVideoOpen_Btn; // 开启视频
  11. [SerializeField] private Button mVideoClose_Btn; // 关闭视频
  12. [SerializeField] private Button mAudioOpen_Btn; // 开启音频
  13. [SerializeField] private Button mAudioClose_Btn; // 关闭音频
  14. [SerializeField] private Button mInvite_Btn; // 邀请用户
  15. [SerializeField] private Button mLeaveRoom; // 离开房间
  16. [SerializeField] private MeshRenderer mBigView_Mesh;
  17. public Texture BigView_MeshTexture
  18. {
  19. set => mBigView_Mesh.material.mainTexture = value;
  20. }
  21. [SerializeField] private RawImage mRawImage_Raw;
  22. public Texture RawImageTexture
  23. {
  24. set => mRawImage_Raw.texture = value;
  25. }
  26. private IRTCService mRTCService;
  27. void Start()
  28. {
  29. mRTCService = this.GetService<IRTCService>();
  30. mVideoOpen_Btn.onClick.AddListener(VideoOpen);
  31. mVideoClose_Btn.onClick.AddListener(VideoClose);
  32. mAudioOpen_Btn.onClick.AddListener(AudioOpen);
  33. mAudioClose_Btn.onClick.AddListener(AudioClose);
  34. mInvite_Btn.onClick.AddListener(Invite);
  35. mLeaveRoom.onClick.AddListener(LeaveRoom);
  36. }
  37. #region UI事件
  38. private void VideoOpen()
  39. {
  40. mRTCService.ActiveVideo(true);
  41. }
  42. private void VideoClose()
  43. {
  44. mRTCService.ActiveVideo(false);
  45. }
  46. private void AudioOpen()
  47. {
  48. mRTCService.ActiveAudio(true);
  49. }
  50. private void AudioClose()
  51. {
  52. mRTCService.ActiveAudio(false);
  53. }
  54. private void Invite()
  55. {
  56. ShowRoom.Instance.window[4].SetActive(true);
  57. if (InviteDlg.Instance) InviteDlg.Instance.ShowHistory();
  58. Debug.LogError($"InviteUser:打开指定窗口");
  59. }
  60. private void LeaveRoom()
  61. {
  62. mRTCService.LeaveRoom();
  63. }
  64. #endregion
  65. private void Update()
  66. {
  67. if(Input.GetKeyDown(KeyCode.Q)) // 用户456加入房间
  68. {
  69. mRTCService.JoinRoom(456);
  70. }
  71. else if(Input.GetKeyDown(KeyCode.Q))
  72. {
  73. }
  74. else if(Input.GetKeyDown(KeyCode.E))
  75. {
  76. }
  77. else if(Input.GetKeyDown(KeyCode.R))
  78. {
  79. }
  80. }
  81. }