增加自定义不是房间的消息发送
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Script;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.UIFarme;
|
||||
@@ -91,6 +92,24 @@ namespace Unity.RenderStreaming
|
||||
public override void Initialize(GameObject panelGo)
|
||||
{
|
||||
base.Initialize(panelGo);
|
||||
_arrowLeft = panelGo.transform.Find("Herder/arrow-left").GetComponent<Button>();
|
||||
_profilePhoto = panelGo.transform.Find("HeadPortraits/MeetingInfoCard").GetComponent<Button>();
|
||||
_profileImage = _profilePhoto.transform.Find("mask/sprite").GetComponent<Image>();
|
||||
_meetingNameInput = panelGo.transform.Find("card/search/InputField").GetComponent<InputField>();
|
||||
_meetingId = panelGo.transform.Find("card/huiyiID/connectionId").GetComponent<Text>();
|
||||
_randomMeetingId = panelGo.transform.Find("card/huiyiID/Button").GetComponent<Button>();
|
||||
_timeDropdown = panelGo.transform.Find("card/time/Dropdown").GetComponent<Dropdown>();
|
||||
_startButton = panelGo.transform.Find("invite").GetComponent<Button>();
|
||||
_spriteAtlas = Resources.Load<SpriteAtlas>("SpriteAtlas");
|
||||
if (_spriteAtlas != null)
|
||||
{
|
||||
_profileSprites = new Sprite[_spriteAtlas.spriteCount];
|
||||
_spriteAtlas.GetSprites(_profileSprites);
|
||||
}
|
||||
|
||||
_profileSpriteIndex = 0;
|
||||
OnClickProfilePhoto();
|
||||
|
||||
renderStreaming = GameObject.FindObjectOfType<SignalingManager>();
|
||||
hostConnection = GameObject.FindObjectOfType<HostConnection>();
|
||||
videoStreamSender = hostConnection.GetComponent<VideoStreamSender>();
|
||||
@@ -110,23 +129,6 @@ namespace Unity.RenderStreaming
|
||||
if (settings?.SignalingSettings != null)
|
||||
renderStreaming.SetSignalingSettings(settings.SignalingSettings);
|
||||
renderStreaming.Run();
|
||||
_arrowLeft = panelGo.transform.Find("Herder/arrow-left").GetComponent<Button>();
|
||||
_profilePhoto = panelGo.transform.Find("HeadPortraits/MeetingInfoCard").GetComponent<Button>();
|
||||
_profileImage = _profilePhoto.transform.Find("mask/sprite").GetComponent<Image>();
|
||||
_meetingNameInput = panelGo.transform.Find("card/search/InputField").GetComponent<InputField>();
|
||||
_meetingId = panelGo.transform.Find("card/huiyiID/connectionId").GetComponent<Text>();
|
||||
_randomMeetingId = panelGo.transform.Find("card/huiyiID/Button").GetComponent<Button>();
|
||||
_timeDropdown = panelGo.transform.Find("card/time/Dropdown").GetComponent<Dropdown>();
|
||||
_startButton = panelGo.transform.Find("invite").GetComponent<Button>();
|
||||
_spriteAtlas = Resources.Load<SpriteAtlas>("SpriteAtlas");
|
||||
if (_spriteAtlas != null)
|
||||
{
|
||||
_profileSprites = new Sprite[_spriteAtlas.spriteCount];
|
||||
_spriteAtlas.GetSprites(_profileSprites);
|
||||
}
|
||||
|
||||
_profileSpriteIndex = 0;
|
||||
OnClickProfilePhoto();
|
||||
}
|
||||
|
||||
public override void OnEnter(Action complete = null)
|
||||
@@ -183,13 +185,38 @@ namespace Unity.RenderStreaming
|
||||
if (string.IsNullOrEmpty(_meetingNameInput.text)) _meetingNameInput.text = $"{meetingId}的房间";
|
||||
}
|
||||
|
||||
private string OnClickRandomUserId()
|
||||
{
|
||||
return $"user_{Random.Range(100, 999)}";
|
||||
}
|
||||
|
||||
private void OnClickStartButton()
|
||||
{
|
||||
this.GetSystem<IGlobalConfigSystem>().SetUserId(OnClickRandomUserId());
|
||||
this.GetSystem<IGlobalConfigSystem>().SetConnectionTimeType(_timeDropdown.value);
|
||||
this.GetSystem<IGlobalConfigSystem>().SetConnectionId(_meetingId.text);
|
||||
hostConnection.RoomConnectionId = this.GetSystem<IGlobalConfigSystem>().GetConnectionId();
|
||||
this.GetSystem<IGlobalConfigSystem>().SetConnectionName(_meetingNameInput.text);
|
||||
this.GetSystem<IGlobalConfigSystem>().SetConnectionTexture(Texture2D.whiteTexture);
|
||||
this.GetSystem<IGlobalConfigSystem>().SetConnectionTexture(_profileImage.sprite.texture);
|
||||
if (!SignalingMessageHelper.IsReady())
|
||||
{
|
||||
Debug.LogError("Signaling 未就绪");
|
||||
return;
|
||||
}
|
||||
|
||||
var avatar = _profileImage.sprite.name.Replace("(Clone)", "");
|
||||
var userInfo = new
|
||||
{
|
||||
type = "host-userInfo",
|
||||
data = new
|
||||
{
|
||||
connectionId = hostConnection.RoomConnectionId,
|
||||
id = this.GetSystem<IGlobalConfigSystem>().GetUserId(),
|
||||
name = _meetingNameInput.text,
|
||||
avatar = $"{this.GetSystem<IGlobalConfigSystem>().IP}/images/head/{avatar}.png"
|
||||
}
|
||||
};
|
||||
SignalingMessageHelper.SendMessage(JsonConvert.SerializeObject(userInfo));
|
||||
SetUp();
|
||||
PanelSystem.PopQueue<StartPanel>();
|
||||
PanelSystem.PushQueue<MainPanel>();
|
||||
|
||||
Reference in New Issue
Block a user