98 lines
2.9 KiB
C#
98 lines
2.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Linq;
|
|
|
|
public class ChoseUserPanel : MonoBehaviour
|
|
{
|
|
SeatBindSubjectItem createRoomSubjectItem1;
|
|
CreateRoomSeatItem createRoomSeatItem1;
|
|
|
|
public VerticalLayoutGroup group;
|
|
public Button tijiaoBtn;
|
|
public Button quxiaoBtn;
|
|
public Button CheckBtn;
|
|
public Button CloseBtn;
|
|
public InputField NameInput;
|
|
public InputField accountInput;
|
|
public ToggleGroup togglegroup;
|
|
|
|
[HideInInspector]
|
|
public GameObject itemPrefb;
|
|
public void Init(SeatBindSubjectItem subjectItem, CreateRoomSeatItem createRoomSeatItem)
|
|
{
|
|
createRoomSubjectItem1 = subjectItem;
|
|
createRoomSeatItem1 = createRoomSeatItem;
|
|
if (itemPrefb==null)
|
|
{
|
|
itemPrefb = Resources.Load<GameObject>("UI/Item/ChoseUserItem");
|
|
}
|
|
|
|
quxiaoBtn.onClick.AddListener(() =>
|
|
{
|
|
Destroy(gameObject);
|
|
});
|
|
CloseBtn.onClick.AddListener(() =>
|
|
{
|
|
Destroy(gameObject);
|
|
});
|
|
|
|
//生成item
|
|
//LoadManage.Instance.allUsers.ForEach(a =>
|
|
//{
|
|
// GameObject obj = Instantiate<GameObject>(itemPrefb, group.transform);
|
|
// if (subjectItem.seatItems.Any(b=>b.useraccount .text== a.login_name))
|
|
// {
|
|
// obj.GetComponent<ChoseUserItem>().Init(a, false, createRoomSeatItem1, this) ;
|
|
// }
|
|
// else
|
|
// {
|
|
// obj.GetComponent<ChoseUserItem>().Init(a, true, createRoomSeatItem1,this);
|
|
// }
|
|
//});
|
|
|
|
//提交
|
|
tijiaoBtn.onClick.AddListener(()=>
|
|
{
|
|
if(togglegroup.AnyTogglesOn())
|
|
{
|
|
Toggle toggle=togglegroup.ActiveToggles().ToList().Find(a => a.isOn);
|
|
toggle.transform.GetComponentInParent<ChoseUserItem>().Chose();
|
|
|
|
|
|
//销毁页面
|
|
Destroy(gameObject);
|
|
}
|
|
});
|
|
|
|
//查询
|
|
CheckBtn.onClick.AddListener(() =>
|
|
{
|
|
if(NameInput.text=="" && accountInput.text=="")
|
|
{
|
|
//显示全部
|
|
group.transform.GetComponentsInChildren<ChoseUserItem>(true).ToList().ForEach(a =>
|
|
{
|
|
a.gameObject.SetActive(true);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
//筛选
|
|
group.transform.GetComponentsInChildren<ChoseUserItem>(true).ToList().ForEach(a =>
|
|
{
|
|
if(a.userName.text.Contains(NameInput.text) && a.userAccount.text.Contains(accountInput.text))
|
|
{
|
|
a.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
a.gameObject.SetActive(false);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|