void AddPanel() { // If previous panel exists, destroy it if (currentPanel != null) { Destroy(currentPanel); } // Instantiate panel currentPanel = Instantiate <GameObject> (prefab); // Update panel texts Text countryName, provinceName, cityName, population; countryName = currentPanel.transform.Find("Panel/RowCountry/CountryName").GetComponent <Text> (); provinceName = currentPanel.transform.Find("Panel/RowProvince/ProvinceName").GetComponent <Text> (); cityName = currentPanel.transform.Find("Panel/RowCity/CityName").GetComponent <Text> (); population = currentPanel.transform.Find("Panel/RowCityData1/CityData1Value").GetComponent <Text> (); // Gets a random city and populate data int cityIndex = Random.Range(0, map.cities.Count - 1); City city = map.GetCity(cityIndex); cityName.text = city.name; population.text = city.population.ToString(); countryName.text = map.GetCityCountryName(cityIndex); provinceName.text = map.GetCityProvinceName(cityIndex); // Position the canvas over the globe float distaceToGlobeCenter = 1.2f; Vector3 worldPos = map.transform.TransformPoint(city.unitySphereLocation * distaceToGlobeCenter); currentPanel.transform.position = worldPos; // Draw a circle around the city map.AddMarker(MARKER_TYPE.CIRCLE_PROJECTED, city.unitySphereLocation, 100, 0.8f, 1f, Color.green); // Parent the panel to the globe so it rotates with it currentPanel.transform.SetParent(map.transform, true); // Finally fly to city to show the panel map.FlyToCity(cityIndex, 2f); }