You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
using UnityEngine; |
|
using System.Collections.Generic; |
|
using UnityEngine.UI; |
|
using UIWidgets; |
|
using AX.NetworkSystem; |
|
using AX.MessageSystem; |
|
|
|
public class UserList : MonoBehaviour { |
|
|
|
// Use this for initialization |
|
public TreeView treeView; |
|
public GameObject itemPrefab; |
|
public List<UserInfo> userList = new List<UserInfo>(); |
|
void Start() |
|
{ |
|
MessageDispatcher.AddListener("USER_DATA_REFRESH", setUserList); |
|
treeView.NodeSelected.AddListener(getUserListRequest); |
|
} |
|
void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("USER_DATA_REFRESH", setUserList); |
|
treeView.NodeSelected.RemoveListener(getUserListRequest); |
|
} |
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
private void getUserListRequest(TreeNode<TreeViewItem> node) |
|
{ |
|
var deptID = (int)node.Item.Tag; |
|
NetworkManager.Default.SendRequestAsync("GET_USER_LIST_REQUEST", deptID); |
|
} |
|
private void setUserList(IMessage message) |
|
{ |
|
userList = (List<UserInfo>)(message.Data); |
|
foreach (Transform child in this.transform) |
|
{ |
|
Destroy(child.gameObject); |
|
} |
|
foreach (UserInfo user in userList) |
|
{ |
|
GameObject item = Instantiate(itemPrefab) as GameObject; |
|
item.transform.parent = transform; |
|
item.name = "Item"; |
|
item.GetComponent<UserSelectMessage>().setUser(user); |
|
item.GetComponent<Toggle>().group = GetComponent<ToggleGroup>(); |
|
} |
|
} |
|
public void resetList() |
|
{ |
|
foreach (Transform child in this.transform) |
|
{ |
|
Destroy(child.gameObject); |
|
} |
|
} |
|
}
|
|
|