using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PersonListToggle : BaseToggle { public Transform Scrollview; public Transform PersonContent; public GameObject PersonListItem; void Start() { //List aa = new List(); //aa.Add(new UserData()); //aa.Add(new UserData()); //aa.Add(new UserData()); //Room r = new Room() //{ // UserList = aa //}; //CurrentUserInfo.room = r; Scrollview = transform.Find("Scroll View"); //for (int i = 0; i < CurrentUserInfo.room.UserList.Count; i++) //{ // GameObject item = Instantiate(PersonListItem, PersonContent); // item.name = CurrentUserInfo.room.UserList[i].UserInfo.RealName; // //item.GetComponent().text = CurrentUserInfo.room.UserList[i].Org.DisplayName;//UserInfo.RealName + "(" + CurrentUserInfo.room.UserList[i].Org+")"; //} } public override void RespondFun(bool value) { Scrollview.gameObject.SetActive(value); if (value) { if (PersonContent.childCount>0) { for (int i = 0; i < PersonContent.childCount; i++) { Destroy(PersonContent.GetChild(i).gameObject); } } ShowPersonList(); } } private void ShowPersonList() { for (int i = 0; i < CurrentUserInfo.room.UserList.Count; i++) { GameObject item = Instantiate(PersonListItem, PersonContent); item.name = CurrentUserInfo.room.UserList[i].UserInfo.RealName; string displayname = CurrentUserInfo.room.UserList[i].Org.DisplayName;//UserInfo.RealName + "(" + CurrentUserInfo.room.UserList[i].Org+")"; if (CurrentUserInfo.room.UserList[i].Org.Level==5) { displayname = CurrentUserInfo.room.UserList[i].Org.DisplayName.Split('_')[0]; } string realname = CurrentUserInfo.room.UserList[i].UserInfo.RealName; string role = CurrentUserInfo.room.UserList[i].Role.ToString(); item.GetComponent().text = displayname + "_" + realname + "(" + role + ")"; } } }