开始开发
This commit is contained in:
53
Assets/Script/CopyFontTextMessage.cs
Normal file
53
Assets/Script/CopyFontTextMessage.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CopyFontTextMessageOrContentSizeFitter : MonoBehaviour
|
||||
{
|
||||
private Text _text;
|
||||
public MessageType messageType;
|
||||
public Text childRect;
|
||||
public RectTransform prentRect;
|
||||
private RectTransform _headRect;
|
||||
private RectTransform _nameRect;
|
||||
private RectTransform _spriteRect;
|
||||
private void Start()
|
||||
{
|
||||
_text=this.GetComponent<Text>();
|
||||
_headRect=prentRect.Find("head").GetComponent<RectTransform>();
|
||||
_nameRect=prentRect.Find("name").GetComponent<RectTransform>();
|
||||
_spriteRect=prentRect.Find("sprite").GetComponent<RectTransform>();
|
||||
if (messageType == MessageType.Text)
|
||||
{
|
||||
_spriteRect.gameObject.SetActive(false);
|
||||
_text.gameObject.SetActive(true);
|
||||
}else if (messageType == MessageType.Sprite)
|
||||
{
|
||||
_spriteRect.gameObject.SetActive(true);
|
||||
_text.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
childRect.text = _text.text;
|
||||
float screenHeight = 0;
|
||||
if (messageType == MessageType.Text)
|
||||
{
|
||||
screenHeight = _headRect.sizeDelta.y+ _nameRect.sizeDelta.y + _text.rectTransform.sizeDelta.y;
|
||||
}else if (messageType == MessageType.Sprite)
|
||||
{
|
||||
screenHeight = _headRect.sizeDelta.y+ _nameRect.sizeDelta.y + _spriteRect.sizeDelta.y;
|
||||
}
|
||||
prentRect.sizeDelta = new Vector2(prentRect.sizeDelta.x, screenHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public enum MessageType
|
||||
{
|
||||
Text,
|
||||
Sprite,
|
||||
}
|
||||
11
Assets/Script/CopyFontTextMessage.cs.meta
Normal file
11
Assets/Script/CopyFontTextMessage.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0d1fae869ba7964eb5460269dce180b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
97
Assets/Script/GlobalConfigSystem.cs
Normal file
97
Assets/Script/GlobalConfigSystem.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IGlobalConfigSystem : ISystem
|
||||
{
|
||||
public string GetConnectionId();
|
||||
public void SetConnectionId(string connectionId);
|
||||
|
||||
public string GetConnectionName();
|
||||
public void SetConnectionName(string connectionName);
|
||||
|
||||
public UniTaskVoid StartConnectionTime();
|
||||
public string GetConnectionTime();
|
||||
|
||||
public void StopConnectionTime();
|
||||
|
||||
}
|
||||
|
||||
public class GlobalConfigSystem : AbstractSystem, IGlobalConfigSystem
|
||||
{
|
||||
private string _connectionId;
|
||||
private string _connectionName;
|
||||
private float _connectionTime;
|
||||
private CancellationTokenSource _cts;
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public string GetConnectionId()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_connectionId))
|
||||
{
|
||||
Debug.LogWarning("GlobalConfigSystem: GetConnectionId not set");
|
||||
return "";
|
||||
}
|
||||
|
||||
return _connectionId;
|
||||
}
|
||||
|
||||
public void SetConnectionId(string connectionId)
|
||||
{
|
||||
_connectionId = connectionId;
|
||||
}
|
||||
|
||||
public string GetConnectionName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_connectionName))
|
||||
{
|
||||
Debug.LogWarning("GlobalConfigSystem: GetConnectionName not set");
|
||||
return "";
|
||||
}
|
||||
|
||||
return _connectionName;
|
||||
}
|
||||
|
||||
public void SetConnectionName(string connectionName)
|
||||
{
|
||||
_connectionName = connectionName;
|
||||
}
|
||||
|
||||
public async UniTaskVoid StartConnectionTime()
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
_connectionTime = 0;
|
||||
while (!_cts.IsCancellationRequested)
|
||||
{
|
||||
_connectionTime+=Time.deltaTime;
|
||||
await UniTask.Yield(_cts.Token); // 等一帧,等价于 Update
|
||||
}
|
||||
}
|
||||
|
||||
public string GetConnectionTime()
|
||||
{
|
||||
int totalSeconds = (int)_connectionTime;
|
||||
int hours = totalSeconds / 3600;
|
||||
int minutes = totalSeconds % 3600 / 60;
|
||||
int seconds = totalSeconds % 60;
|
||||
return $"{hours:D2}:{minutes:D2}:{seconds:D2}";
|
||||
}
|
||||
|
||||
public void StopConnectionTime()
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts?.Dispose();
|
||||
_cts = null;
|
||||
}
|
||||
}
|
||||
11
Assets/Script/GlobalConfigSystem.cs.meta
Normal file
11
Assets/Script/GlobalConfigSystem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf37d8709d428da45a390015668c612f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Script/MainArchitecture.cs
Normal file
15
Assets/Script/MainArchitecture.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Stary.Evo;
|
||||
|
||||
namespace RenderStreaming
|
||||
{
|
||||
public class MainArchitecture : Architecture<MainArchitecture>
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
//注册示例
|
||||
//RegisterSystem<IScoreSystem>(new ScoreSystem());
|
||||
RegisterSystem<IGlobalConfigSystem>(new GlobalConfigSystem());
|
||||
RegisterSystem<ITimerSystem>(new TimerSystem());
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Script/MainArchitecture.cs.meta
Normal file
3
Assets/Script/MainArchitecture.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94ef042a14804dfd965107b572bf7d81
|
||||
timeCreated: 1778552415
|
||||
26
Assets/Script/MeetingChatController.cs
Normal file
26
Assets/Script/MeetingChatController.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RenderStreaming;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
public class MeetingChatController : MonoBehaviour,IController
|
||||
{
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IArchitecture GetArchitecture()
|
||||
{
|
||||
return MainArchitecture.Interface;
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Script/MeetingChatController.cs.meta
Normal file
11
Assets/Script/MeetingChatController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd96585787c8a4d42b3ad979cf3e31e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Script/MeetingContactsController.cs
Normal file
25
Assets/Script/MeetingContactsController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RenderStreaming;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
public class MeetingContactsController : MonoBehaviour ,IController
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IArchitecture GetArchitecture()
|
||||
{
|
||||
return MainArchitecture.Interface;
|
||||
}
|
||||
}
|
||||
11
Assets/Script/MeetingContactsController.cs.meta
Normal file
11
Assets/Script/MeetingContactsController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19625967ea163c04095b4ef20880146a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Script/MeetingInfoListController.cs
Normal file
35
Assets/Script/MeetingInfoListController.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RenderStreaming;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
|
||||
public class MeetingInfoList : MonoBehaviour, IController
|
||||
{
|
||||
public Dictionary<GameObject, MeetingInfo> Meetings;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Meetings = new Dictionary<GameObject, MeetingInfo>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public IArchitecture GetArchitecture()
|
||||
{
|
||||
return MainArchitecture.Interface;
|
||||
}
|
||||
|
||||
public class MeetingInfo
|
||||
{
|
||||
public Texture2D Icon;
|
||||
public string Name;
|
||||
public string Message;
|
||||
public bool Ismic;
|
||||
public bool Iscam;
|
||||
}
|
||||
}
|
||||
11
Assets/Script/MeetingInfoListController.cs.meta
Normal file
11
Assets/Script/MeetingInfoListController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e57592024ba7ab4ab283f87f98a49e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
Assets/Script/TabChangeController.cs
Normal file
69
Assets/Script/TabChangeController.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RenderStreaming;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TabChangeController : MonoBehaviour, IController
|
||||
{
|
||||
private Toggle _meetingTog;
|
||||
private Toggle _chatTog;
|
||||
private Toggle _contactTog;
|
||||
|
||||
private GameObject _meetingInfoList;
|
||||
private GameObject _meetingChat;
|
||||
private GameObject _meetingContacts;
|
||||
void Start()
|
||||
{
|
||||
_meetingTog = transform.Find("MeetingOrganizers").GetComponent<Toggle>();
|
||||
_chatTog = transform.Find("Chat").GetComponent<Toggle>();
|
||||
_contactTog = transform.Find("Contacts").GetComponent<Toggle>();
|
||||
_meetingInfoList = transform.parent.Find("MeetingInfoList").gameObject;
|
||||
_meetingChat = transform.parent.Find("MeetingChat").gameObject;
|
||||
_meetingContacts = transform.parent.Find("MeetingContacts").gameObject;
|
||||
_meetingTog.onValueChanged.AddListener(OnMeetingOrganizers);
|
||||
_chatTog.onValueChanged.AddListener(OnChat);
|
||||
_contactTog.onValueChanged.AddListener(OnContacts);
|
||||
|
||||
|
||||
|
||||
_meetingTog.isOn = true;
|
||||
}
|
||||
private void OnMeetingOrganizers(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
_meetingInfoList.SetActive(true);
|
||||
_meetingChat.SetActive(false);
|
||||
_meetingContacts.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnChat(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
_meetingInfoList.SetActive(false);
|
||||
_meetingChat.SetActive(true);
|
||||
_meetingContacts.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnContacts(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
_meetingInfoList.SetActive(false);
|
||||
_meetingChat.SetActive(false);
|
||||
_meetingContacts.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IArchitecture GetArchitecture()
|
||||
{
|
||||
return MainArchitecture.Interface;
|
||||
}
|
||||
}
|
||||
11
Assets/Script/TabChangeController.cs.meta
Normal file
11
Assets/Script/TabChangeController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 261698e23772dc34c865d650af64eab7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Script/WebRtc.meta
Normal file
8
Assets/Script/WebRtc.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87067ac77908f444c8320d5d11fe62bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Script/WebRtc/MessageChannel.cs
Normal file
26
Assets/Script/WebRtc/MessageChannel.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// Assets/Script/MessageChannel.cs
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.RenderStreaming
|
||||
{
|
||||
public class MessageChannel : DataChannelBase
|
||||
{
|
||||
public event Action<string, string> OnMessageReceived; // connectionId, message
|
||||
|
||||
protected override void OnMessage(byte[] bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = Encoding.UTF8.GetString(bytes);
|
||||
Debug.Log($"[MessageChannel] Received: {json}");
|
||||
OnMessageReceived?.Invoke(ConnectionId, json);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[MessageChannel] Parse error: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Script/WebRtc/MessageChannel.cs.meta
Normal file
11
Assets/Script/WebRtc/MessageChannel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6d9a920c56cc474db27ac4ed56a219a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user