using Byn.Unity.Examples; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.Pool; using UnityEngine.UI; using WI; namespace SHINT.UI { public class UI_ActiveUserCount : MonoBehaviour { int userCount; public GameObject prf_UserIcon; TextMeshProUGUI userCounter; Image activeState; public RectTransform userIconContainer; ObjectPool iconPool; List activeIcons = new(); public override void AfterStart() { iconPool = new ObjectPool(CreateIcon, GetIcon, ReleaseIcon, null, true, 20); } void ReleaseIcon(GameObject icon) { activeIcons.Remove(icon); icon.SetActive(false); } void GetIcon(GameObject icon) { activeIcons.Add(icon); icon.SetActive(true); } GameObject CreateIcon() { var icon = Instantiate(prf_UserIcon); icon.transform.SetParent(userIconContainer); icon.transform.localScale = new Vector3(1, 1, 1); icon.SetActive(false); return icon; } public void SetActivateUserCount(int count) { activeState.color = count == 0 ? Color.gray : Color.green; userCount = count; //userCounter.text = userCount.ToString(); int c = activeIcons.Count; for(int i =0;i().SetId("Guest_"+i.ToString()); } } } }