两个页面接入完成
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Script
|
||||
/// Key: 参与者ID
|
||||
/// Value: 联系人列表项实例
|
||||
/// </summary>
|
||||
private readonly Dictionary<GameObject, ContactEntryController> _contactEntries = new();
|
||||
private readonly List<ContactEntryController> _contactEntries = new();
|
||||
|
||||
private Image _avatarImage;
|
||||
private Button _cancelButton;
|
||||
@@ -39,10 +39,12 @@ namespace Script
|
||||
private Text _messageText;
|
||||
private Text _nameText;
|
||||
|
||||
private GameObject _panelGo;
|
||||
public GameObject PanelGo;
|
||||
|
||||
public ContactEntryController CurrentEntry { get; set; }
|
||||
|
||||
private GameObjectPool _objectPool;
|
||||
|
||||
public IArchitecture GetArchitecture()
|
||||
{
|
||||
return MainArchitecture.Interface;
|
||||
@@ -50,12 +52,12 @@ namespace Script
|
||||
|
||||
public void Initialize(GameObject panelGo)
|
||||
{
|
||||
_panelGo = panelGo;
|
||||
PanelGo = panelGo;
|
||||
_contactEntryPrefab = Resources.Load<GameObject>("ContactEntry");
|
||||
_content = _panelGo.transform.Find("MeetingGrid/Viewport/Content");
|
||||
_content = PanelGo.transform.Find("MeetingGrid/Viewport/Content");
|
||||
|
||||
//邀请界面
|
||||
_confirmingPop = _panelGo.transform.Find("MeetingGrid/ConfirmingPop").gameObject;
|
||||
_confirmingPop = PanelGo.transform.Find("MeetingGrid/ConfirmingPop").gameObject;
|
||||
_confirmingPop.SetActive(false);
|
||||
//确认邀请
|
||||
_idText = _confirmingPop.transform.Find("bg/id").GetComponent<Text>();
|
||||
@@ -66,21 +68,28 @@ namespace Script
|
||||
_avatarImage = _confirmingPop.transform.Find("ParticipantEntry/head").GetComponent<Image>();
|
||||
_nameText = _confirmingPop.transform.Find("ParticipantEntry/Name").GetComponent<Text>();
|
||||
_messageText = _confirmingPop.transform.Find("ParticipantEntry/Message").GetComponent<Text>();
|
||||
|
||||
_objectPool = PanelGo.transform.Find("MeetingGrid/Pool").GetComponent<GameObjectPool>();
|
||||
}
|
||||
|
||||
public async void OnEnter()
|
||||
{
|
||||
foreach (var entry in _contactEntries)
|
||||
_objectPool.Release(entry.gameObject);
|
||||
_contactEntries.Clear();
|
||||
var response =
|
||||
await WebRequestSystem.Get<ResponseUsers>(this.GetSystem<IGlobalConfigSystem>().IP, "/signaling/users");
|
||||
await WebRequestSystem.Get<MainPanel.ResponseUsers>(this.GetSystem<IGlobalConfigSystem>().IP,
|
||||
"/signaling/users");
|
||||
if (response != null && response.totalCount > 0)
|
||||
for (var i = 0; i < response.totalCount; i++)
|
||||
{
|
||||
var item = response.users[i];
|
||||
if (string.IsNullOrEmpty(item.name) ||
|
||||
string.IsNullOrEmpty(item.userId)) continue;
|
||||
var entry = GameObject.Instantiate(_contactEntryPrefab, _content);
|
||||
var entry = _objectPool.Get();
|
||||
var contactEntryController = entry.GetOrAddComponent<ContactEntryController>();
|
||||
contactEntryController.SetData(item, this);
|
||||
_contactEntries.Add(contactEntryController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +98,7 @@ namespace Script
|
||||
{
|
||||
}
|
||||
|
||||
public void ClickContactEntry(Sprite avatarImage, string name, UsersItem item)
|
||||
public void ClickContactEntry(Sprite avatarImage, string name, MainPanel.UsersItem item)
|
||||
{
|
||||
_confirmingPop.SetActive(true);
|
||||
|
||||
@@ -119,7 +128,8 @@ namespace Script
|
||||
inviterName = this.GetSystem<IGlobalConfigSystem>().GetConnectionName(),
|
||||
inviterAvatar =
|
||||
$"{this.GetSystem<IGlobalConfigSystem>().IP}/images/head/" +
|
||||
$"{this.GetSystem<IGlobalConfigSystem>().GetConnectionTexture().name}.png"
|
||||
$"{this.GetSystem<IGlobalConfigSystem>().GetConnectionTexture()}.png",
|
||||
applyReason = _leaveMessage.text
|
||||
}
|
||||
};
|
||||
SignalingMessageHelper.SendMessage(JsonConvert.SerializeObject(userInfo));
|
||||
@@ -130,59 +140,5 @@ namespace Script
|
||||
CurrentEntry = null;
|
||||
});
|
||||
}
|
||||
|
||||
public class ContactEntryData
|
||||
{
|
||||
public string avatar;
|
||||
public GameObject entry;
|
||||
public Toggle invitationTog;
|
||||
public string name;
|
||||
public string participantId;
|
||||
public string role;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ResponseUsers
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public List<UsersItem> users { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public int totalCount { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class UsersItem
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public string socketId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public string connectionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public string participantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public string role { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public string userId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public string avatar { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user