using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SenderWinManager : MonoBehaviour { public List zhongDuiUsersInRoom = new List(); public GameObject senderItem; public GameObject Content; // Use this for initialization void Awake () { Content = transform.Find("Scroll View/Viewport/Content").gameObject; if (CurrentUserInfo.room != null) { foreach (UserData item in CurrentUserInfo.room.UserList) { if (item.Org.Level == 4 /*&& item.UserInfo.Id != CurrentUserInfo.mySelf.Id*/) {//作战部署接收者显示所有中队,不然总指挥是中队时,无法发给他自己的上下级 zhongDuiUsersInRoom.Add(item); } } } foreach (UserData item in zhongDuiUsersInRoom) { GameObject receive = GameObject.Instantiate(senderItem, Content.transform) as GameObject; receive.transform.Find("Label").GetComponent().text = item.Org.DisplayName; receive.GetComponent().receiverUser = item; } } private void OnEnable() { zhongDuiUsersInRoom.Clear(); if (CurrentUserInfo.room != null) { foreach (UserData item in CurrentUserInfo.room.UserList) { if (item.Org.Level == 4 /*&& item.UserInfo.Id != CurrentUserInfo.mySelf.Id*/) {//作战部署接收者显示所有中队,不然总指挥是中队时,无法发给他自己的上下级 zhongDuiUsersInRoom.Add(item); } } } foreach (Transform item in Content.transform) { Destroy(item.gameObject); } foreach (UserData item in zhongDuiUsersInRoom) { GameObject receive = GameObject.Instantiate(senderItem, Content.transform) as GameObject; receive.transform.Find("Label").GetComponent().text = item.Org.DisplayName; receive.GetComponent().receiverUser = item; } } // Update is called once per frame void Update () { } }