void AddBallAtPosition(Vector2 pos) { GameObject ball = GameObject.CreatePrimitive(PrimitiveType.Sphere); ball.GetComponent <Renderer>().sharedMaterial.color = Color.yellow; map.AddMarker3DObject(ball, pos, 0.03f); }
void ToggleFrontierSpainFrance() { List<Vector2> blockedPositions = map.GetCountryFrontierPoints(map.GetCountryIndex("France"), map.GetCountryIndex("Spain"), 1); canCross = !canCross; map.PathFindingCustomRouteMatrixSet(blockedPositions, canCross ? -1 : 0); if (canCross) { for(int k=0;k<blocks.Count;k++) { Destroy(blocks[k]); } blocks.Clear(); } else { blocks.Clear(); foreach(Vector2 blockPosition in blockedPositions) { GameObject o = GameObject.CreatePrimitive(PrimitiveType.Cube); map.AddMarker3DObject(o, blockPosition, 0.05f); blocks.Add(o); } } }
/// <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 AddMarker3DObjectOnRandomCity() { // Every marker is put on a plane-coordinate (in the range of -0.5..0.5 on both x and y) Vector2 planeLocation; // Add a marker on a random city City city = map.cities[Random.Range(0, map.cities.Length)]; planeLocation = city.unity2DLocation; // or... choose a city by its name: // int cityIndex = map.GetCityIndex("Moscow"); // planeLocation = map.cities[cityIndex].unity2DLocation; // or... use the centroid of a country // int countryIndex = map.GetCountryIndex("Greece"); // planeLocation = map.countries[countryIndex].center; // or... use a custom location lat/lon. Example put the building over New York: // map.calc.fromLatDec = 40.71f; // 40.71 decimal degrees north // map.calc.fromLonDec = -74.00f; // 74.00 decimal degrees to the west // map.calc.fromUnit = UNIT_TYPE.DecimalDegrees; // map.calc.Convert(); // planeLocation = map.calc.toPlaneLocation; // Send the prefab to the AddMarker API setting a scale of 0.1f (this depends on your marker scales) GameObject tower = Instantiate(Resources.Load <GameObject>("Tower/tower")); map.AddMarker3DObject(tower, planeLocation, 1f); // Fly to the destination and see the building created map.FlyToLocation(planeLocation, 2f, 0.2f); // Optionally add a blinking effect to the marker MarkerBlinker.AddTo(tower, 3, 0.2f); }