闪黑问题
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// D:\Project\Unity\webrtc\Assets\Script\MultiParticipantHostSample.cs
|
||||
// D:\Project\Unity\webrtc\Assets\Script\MultiParticipantHostSample.cs
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@@ -165,7 +165,9 @@ namespace Unity.RenderStreaming
|
||||
// 绑定视频:当Receiver收到纹理时更新RawImage
|
||||
ps.videoReceiver.OnUpdateReceiveTexture += texture =>
|
||||
{
|
||||
if (ui.videoImage != null)
|
||||
ui.videoImage.color = Color.white;
|
||||
// 防止纹理为null时导致RawImage闪黑(重协商/track切换时可能短暂为null)
|
||||
if (ui.videoImage != null && texture != null)
|
||||
ui.videoImage.texture = texture;
|
||||
};
|
||||
|
||||
@@ -208,7 +210,6 @@ namespace Unity.RenderStreaming
|
||||
// 根节点
|
||||
ui.root = new GameObject($"ParticipantUI_{participantId}");
|
||||
ui.root.transform.SetParent(participantVideoContainer, false);
|
||||
|
||||
// 添加VerticalLayoutGroup使内容垂直排列
|
||||
var vlg = ui.root.AddComponent<VerticalLayoutGroup>();
|
||||
vlg.childControlWidth = true;
|
||||
@@ -216,7 +217,8 @@ namespace Unity.RenderStreaming
|
||||
vlg.childForceExpandWidth = true;
|
||||
vlg.childForceExpandHeight = false;
|
||||
vlg.spacing = 2;
|
||||
|
||||
ui.root.transform.GetComponent<RectTransform>().anchorMin = Vector2.zero;
|
||||
ui.root.transform.GetComponent<RectTransform>().anchorMax = Vector2.one;
|
||||
// 名称标签
|
||||
var labelObj = new GameObject("NameLabel");
|
||||
labelObj.transform.SetParent(ui.root.transform, false);
|
||||
|
||||
Reference in New Issue
Block a user