public void UpdateButtonClick() { string countryName = countriesDropdown.captionText.text; Country country = map.GetCountry(countryName); if (country == null) { return; } string resourcesValue = resourcesInputField.text; country.attrib [RESOURCE_NAME] = resourcesValue; GameObject txt = GameObject.Find(countryName + "_ResourcesText"); if (txt == null) { TextMesh tm = map.AddMarker2DText("$" + resourcesValue, country.center); tm.transform.localScale *= 10f; tm.gameObject.name = countryName + "_ResourcesText"; } else { txt.GetComponent <TextMesh> ().text = "$" + resourcesValue; } }
/// <summary> /// Illustrates how to add custom markers over the map using the AddMarker API. /// In this example a building prefab is added to a random city (see comments for other options). /// </summary> void AddMarkerTextOnRandomPlace() { // Every marker is put on a plane-coordinate (in the range of -0.5..0.5 on both x and y) Vector2 planeLocation = new Vector2(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f)); // Add the text TextMesh tm = map.AddMarker2DText("Random Caption", planeLocation); tm.color = Color.yellow; // Fly to the destination and see the building created map.FlyToLocation(planeLocation, 2f, 0.1f); // Optionally add a blinking effect to the marker MarkerBlinker.AddTo(tm.gameObject, 3, 0.2f); }
void ShowPathAndCosts(List <int> path) { int steps = path.Count; Color pathColor = new Color(0.5f, 0.5f, 0, 0.5f); for (int k = 1; k < steps; k++) // ignore step 0 since this is current tank cell { int cellIndex = path [k]; // Color path cells map.SetCellTemporaryColor(cellIndex, pathColor); // Show the accumulated cost int accumCost = map.GetCellPathCost(cellIndex); Vector3 cellPosition = map.GetCellPosition(cellIndex); TextMesh text = map.AddMarker2DText(accumCost.ToString(), cellPosition); text.transform.localScale *= 0.3f; // make font smaller texts.Add(text); } }