public void Open(List <iActivityPlace> openedActivities) { Game game = Game.GetInstantiate(); gameObject.SetActive(true); prevState = game.GetGameState(); game.ChangeGameState(GameState.IN_ACTIVITIES_PANEL); activities = openedActivities; float height = 0; foreach (iActivityPlace activity in activities) { if (activity is QuestEvent) { EventPanel eventPanel = Instantiate(eventPanelPrefab, activitiesContent); eventPanel.questEvent = (QuestEvent)activity; eventPanel.GetComponent <RectTransform>().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, height, eventPanel.GetHeight()); height += eventPanel.GetHeight(); } else if (activity is Office) { OfficePanel officePanel = Instantiate(officePanelPrefab, activitiesContent); officePanel.office = (Office)activity; officePanel.GetComponent <RectTransform>().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, height, officePanel.GetHeight()); height += officePanel.GetHeight(); } } height += 20; RectTransform rect = GetComponent <RectTransform>(); if (height > Screen.height - 20 - 120) { rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Screen.height - 20 - 120); } else { rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); } CheckAccept(); }