Browse Source

修改取消退出房间逻辑 和 房间内RTC音频播放Bug

DGJ 1 year ago
parent
commit
902b15a451

+ 18 - 2
Assets/Game/Blue/Controller/LangChaoRommMinIo.cs

@@ -141,10 +141,20 @@ public class LangChaoRommMinIo : MonoSingleton<LangChaoRommMinIo>
                                     .WithSessionToken(minioToken)
                                     .WithSSL(isHttps)
                                     .Build();
+               
+                var minioTest = new MinioClient()
+                                    .WithEndpoint(endpoint)
+                                    .WithCredentials(accessKey, secretKey)
+                                    .WithSessionToken(minioToken)
+                                    .WithSSL(isHttps)
+                                    .Build();
+
+                
+
                 TimerMgr.Instance.CreateTimer(() =>
                 {
 
-                    minio = null;
+                   // minio = null;
                 }, 1200);
                 callBack?.Invoke(true);
             }
@@ -163,8 +173,14 @@ public class LangChaoRommMinIo : MonoSingleton<LangChaoRommMinIo>
         if (this.projectId!= roomId)
         {
             this.projectId = roomId;
-            minio = null;
+          //  minio = null;
         }
+        //Unity 当执行大量null 引用操作的时候 下面的方法比  gameobject!=null  快了大概两倍
+        if (!System.Object.ReferenceEquals(gameObject, null))
+        {
+
+        }
+
         GetFileData getFileData = new GetFileData();
         getFileData.bucket = bucket;
         getFileData.objectName = objectName;

+ 17 - 1
Assets/Game/ShowSupport/SupportControl.cs

@@ -133,7 +133,23 @@ public class SupportControl : AbstractController
 
     public void LeaveRoom()
     {
-        RTCRoomManager.Instance.LeaveChannel();
+        switch (RTCRoomManager.Instance.rtcState)
+        {
+            case RTCEnum.OFF:
+            case RTCEnum.Online:
+                RTCRoomManager.Instance.LeaveChannel();
+                break;
+            case RTCEnum.ExpertOnline:
+                break;
+            case RTCEnum.ConterlOnline:
+                break;
+            case RTCEnum.ALLOnline:
+                break;
+            default:
+                break;
+        }
+
+       
     }
 
     /// <summary>

+ 1 - 1
Assets/Game/ShowXunJian/StartXunJian.cs

@@ -70,7 +70,7 @@ namespace GHZLangChao
         {
 #if UNITY_EDITOR
             //if (Test) return;
-            //return;
+            return;
 #endif
             OnReset?.Invoke();
         }

+ 5 - 5
Assets/Scripts/RTC/LiveRTCRoomMain.cs

@@ -33,17 +33,17 @@ public class LiveRTCRoomMain : MonoSingleton<LiveRTCRoomMain>,IController
     {
         if (RTCRoomManager.Instance.expertView != null)
         {
-            if (!rtcRawImage.gameObject.activeSelf)
-                rtcRawImage.gameObject.SetActive(true);
+            //if (!rtcRawImage.gameObject.activeSelf)
+            //    rtcRawImage.gameObject.SetActive(true);
 
             rtcRawImage.texture = RTCRoomManager.Instance.expertView.VideoView;
         }
         else
         {
-            if (rtcRawImage.gameObject.activeSelf)
-                rtcRawImage.gameObject.SetActive(false);
+            //if (rtcRawImage.gameObject.activeSelf)
+            //    rtcRawImage.gameObject.SetActive(false);
         }
-          
+
     }
     private void OnInit()
     {

+ 43 - 4
Assets/Scripts/RTC/RTCRoomManager.cs

@@ -25,6 +25,11 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
     public JObject controlData;
 
     public bool isRTCreate;
+
+    public GameObject audio1;
+    public GameObject audio2;
+
+    public Dictionary<string, AudioSource> dicAudio;
     private void Start()
     {
         this.RegisterEvent<RTCCreatRoomSuccessEvent>(CreatRoomSuccess).UnRegisterWhenGameObjectDestroyed(gameObject);
@@ -32,6 +37,8 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
         rtcState = RTCEnum.OFF;
         question = QuestionEnum.NetWork;
         isRTCreate = false;
+
+        RTCManager.OnRemoteVideoStateChanged += RemoteVideoStateChanged;
     }
     private void Update()
     {
@@ -40,7 +47,33 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
             isRTCreate = false;
             this.GetService<IRTCService>().CreatRoom();
         }
-       
+       // Debug.Log(" GETWindow Scenes   " + ScenesManager.Instance.getWindow());
+    }
+
+    private void RemoteVideoStateChanged(string uid, REMOTE_VIDEO_STATE_REASON_RTC state)
+    {
+        Debug.Log("RemoteVideoStateChanged " + uid +"     "+ state.ToString());
+        switch (state)
+        {
+            case REMOTE_VIDEO_STATE_REASON_RTC.REMOTE_VIDEO_STATE_REASON_NETWORK_CONGESTION:
+                break;
+            case REMOTE_VIDEO_STATE_REASON_RTC.REMOTE_VIDEO_STATE_REASON_NETWORK_RECOVERY:
+                break;
+            case REMOTE_VIDEO_STATE_REASON_RTC.REMOTE_VIDEO_STATE_REASON_LOCAL_MUTED:
+                break;
+            case REMOTE_VIDEO_STATE_REASON_RTC.REMOTE_VIDEO_STATE_REASON_LOCAL_UNMUTED:
+                break;
+            case REMOTE_VIDEO_STATE_REASON_RTC.REMOTE_VIDEO_STATE_REASON_REMOTE_MUTED:
+                LiveRTCRoomMain.Instance.rtcRawImage.gameObject.SetActive(false);
+                break;
+            case REMOTE_VIDEO_STATE_REASON_RTC.REMOTE_VIDEO_STATE_REASON_REMOTE_UNMUTED:
+                LiveRTCRoomMain.Instance.rtcRawImage.gameObject.SetActive(true);
+                break;
+            case REMOTE_VIDEO_STATE_REASON_RTC.REMOTE_VIDEO_STATE_REASON_REMOTE_OFFLINE:
+                break;
+            default:
+                break;
+        }
     }
 
     private void CreatRoomSuccess(RTCCreatRoomSuccessEvent e)
@@ -103,7 +136,7 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
 
     public void UserJoined( UserEnum userEnum , JObject metadata = null)
     {
-       // Debug.Log("DGJ ===> " + rtcState);
+        Debug.Log("DGJ ===> " + rtcState);
         switch (userEnum)
         {
             case UserEnum.Player:
@@ -239,13 +272,19 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
                 break;
         }
 
-        if(rtcState != RTCEnum.OFF&& !(ScenesManager.Instance.getWindow() == ScenesManager.SceneType.ShowRoom|| ScenesManager.Instance.getWindow() == ScenesManager.SceneType.ShowRTC))
+        if (rtcState != RTCEnum.OFF && !(ScenesManager.Instance.getWindow() == ScenesManager.SceneType.ShowRoom || ScenesManager.Instance.getWindow() == ScenesManager.SceneType.ShowRTC))
         {
             Debug.Log(" GETWindow Scenes   " + ScenesManager.Instance.getWindow());
             // 退出房间
             LeaveChannel();
         }
-         
+
+        //if(rtcState == RTCEnum.Online && !(ScenesManager.Instance.getWindow() == ScenesManager.SceneType.ShowRoom || ScenesManager.Instance.getWindow() == ScenesManager.SceneType.ShowRTC))
+        //{
+        //    Debug.Log(" GETWindow Scenes   " + ScenesManager.Instance.getWindow());
+        //    // 退出房间
+        //    LeaveChannel();
+        //}
     }
 
     public void LeaveChannel()

+ 8 - 6
Assets/Scripts/Tool/HeadBtnManager.cs

@@ -68,19 +68,21 @@ public class HeadBtnManager : MonoSingleton<HeadBtnManager>, IController
     public UnityEvent OnReset = new UnityEvent();
     private void Update()
     {
-        OnReset?.Invoke();
+      //  OnReset?.Invoke();
 
-        if (uiFollow != null && (rtcBtn.gameObject.activeSelf == true) && (rtcBtn.gameObject.activeSelf == uiFollow.gameObject.activeSelf))
+        if (uiFollow != null&& rtcBtn.gameObject.activeSelf&& uiFollow.transform.position.z<9000)
         {
-            uiFollow.gameObject.SetActive(false);
+            uiFollow.transform.position = new Vector3(0, 0, 10000);
+            rtcBtn.gameObject.SetActive(!uiFollow.state);
         }
-/*
+
+#if !UNITY_EDITOR
         player.position =OpenXRCamera.Instance.head.transform.position;
         player.eulerAngles = new Vector3(0,OpenXRCamera.Instance.head.transform.eulerAngles.y, 0);
        
         transform.position = OpenXRCamera.Instance.head.position + player.transform.forward * 1.5f + new Vector3(0f, 0f, 0.1f);
-        transform.eulerAngles = player.eulerAngles;*/
-        
+        transform.eulerAngles = player.eulerAngles;
+#endif
     }
 
     public void ShowResetBtn(ScenesManager.SceneType type , UIFollow uiFollow)

+ 3 - 3
Assets/Scripts/Tool/UIFollow.cs

@@ -10,7 +10,7 @@ public class UIFollow : MonoBehaviour
 
     public Vector3 pos;
 
-    private bool state = true;
+    public bool state = true;
 
     private void OnEnable()
     {
@@ -54,7 +54,7 @@ public class UIFollow : MonoBehaviour
     public void Hide()
     {
         state = false;
-        // gameObject.SetActive(false);
+        
         transform.position = new Vector3(0,0,10000);
         HeadBtnManager.Instance.ShowResetBtn(type, this);
     }
@@ -70,7 +70,7 @@ public class UIFollow : MonoBehaviour
 
         transform.position = pos;
         transform.eulerAngles = new Vector3(0,OpenXRCamera.Instance.head.transform.eulerAngles.y, 0);
-        // gameObject.SetActive(true);
+       
         if (type == ScenesManager.SceneType.ShowRTC)
             ShowRoom.Instance.ResetPosition();
 

+ 19 - 1
Assets/Scripts/UICallManager.cs

@@ -100,7 +100,25 @@ public class UICallManager : MonoSingleton<UICallManager>,IController
     public void OnnoExpert()
     {
         // 退出房间
-        RTCRoomManager.Instance.LeaveChannel();
+
+        switch (RTCRoomManager.Instance.rtcState)
+        {
+            case RTCEnum.OFF:
+            case RTCEnum.Online:
+                RTCRoomManager.Instance.LeaveChannel();
+                break;
+            case RTCEnum.ExpertOnline:
+                break;
+            case RTCEnum.ConterlOnline:
+                break;
+            case RTCEnum.ALLOnline:
+                break;
+            default:
+                break;
+        }
+
+
+     //   RTCRoomManager.Instance.LeaveChannel();
 
         // 改文字UI
         //   AllotPanel.Instance.SetAllotText("");