// @tcottin was previously `getRequest()` // show the current page of events public void ShowPage() { if (roomId == -1) { return; } string response = HTTPQuerier.PerformHTTPQuery(API_URL + roomId + "?page=" + page); //Transform target = GameObject.Find("Target").GetComponent<Transform>(); //var canevaTemp = GameObject.Instantiate(Resources.Load("Canevas"), Vector3.zero, Quaternion.identity) as GameObject; RectTransform canevasContainer = canevas.GetComponent <RectTransform>(); //canevasContainer.SetParent(target); //canevasContainer.anchoredPosition = new Vector3(0, 0, 0); //canevasContainer.anchoredPosition = target.transform.position; int y = 160; // Clear previous events foreach (GameObject item in roomEventUIs) { GameObject.Destroy(item); } roomEventUIs.Clear(); // Parse data as JSON Debug.Log("Received: " + response); JSONNode jsonObject = JSON.Parse(response); JSONArray jsonRoomEvents = jsonObject["data"].AsArray; hasNext = jsonObject["hasNext"].AsBool; manageVisibility(); // Create events view for (int i = 0; i < jsonRoomEvents.Count; i++) { RoomEvent room = RoomEvent.fromJson(jsonRoomEvents[i]); var roomEventUI = GameObject.Instantiate(Resources.Load("RoomEventUI"), Vector3.zero, Quaternion.identity) as GameObject; roomEventUIs.Add(roomEventUI); roomEventUI.name = i + ""; // Place item roomEventUI.transform.SetParent(canevasContainer, false); roomEventUI.transform.localScale = new Vector3(1, 1, 1); roomEventUI.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, y, 0); y = y - 110; // Set width RectTransform rt = (RectTransform)roomEventUI.transform; rt.sizeDelta = new Vector2(canevasContainer.rect.width - 50, rt.rect.height); Text[] texts = roomEventUI.GetComponentsInChildren <Text>(); setupTexts(texts, room, canevasContainer); // Set pane title // FIXME : I'm ugly - Ask the api man to retrieved the room name, even without events. Tks, biz. Text txtRoom = GameObject.Find("txtRoom").GetComponent <Text>(); txtRoom.text = room.Location; } }