using UnityEngine; using UnityEngine.UI; using UniRx; using System; public class FloorButtonsPanel : UIView { private GameObject Item; public FloorData Data = new FloorData(); public override void Awake() { base.Awake(); Item = Find("Scroll View/Viewport/Content/Item"); var url = HttpManager.Instance.GetFloorButtons; HttpManager.Instance.Get(url, data => { Data = data; FloorShortcuts.Instance.Highest = Data.Highest; FloorShortcuts.Instance.Lowest = Data.Lowest; FloorShortcuts.Instance.CurrentNumber = Data.Highest; FloorShortcuts.Instance.Buildingfilter = "Floor"; LoadButtons(); }); } private void LoadButtons() { foreach (var floor in Data.Floors) { GameObject go = GameObject.Instantiate(Item); go.SetActive(true); go.transform.SetParent(Item.transform.parent, false); go.name = floor.ButtonName; go.transform.Find("Label").GetComponent().text = floor.FloorName; go.GetComponent().Prefix = Data.Prefix; go.GetComponent().HighestFloor = Data.Highest; go.GetComponent().LowestFloor = Data.Lowest; go.GetComponent().isRefugeFloor = floor.BNC; go.GetComponent().isFireCompartment = floor.FHFQ; go.GetComponent().isFireDoor = floor.FM; go.GetComponent().isFireShutter = floor.FHJL; go.GetComponent().isHydrant = floor.SNXHS; go.GetComponent().isFireControlRoom = floor.XKS; go.GetComponent().isPumpRoom = floor.BFSX; } } }