public void DestroyCurrentMap() { GOMap map = GetComponent <GOMap> (); if (map == null) { Debug.LogError("[GOMap Editor] GOMap script not found"); return; } while (map.transform.childCount > 0) { foreach (Transform child in map.transform) { GameObject.DestroyImmediate(child.gameObject); } } GOEnvironment env = GameObject.FindObjectOfType <GOEnvironment>(); if (env == null) { return; } while (env.transform.childCount > 0) { foreach (Transform child in env.transform) { GameObject.DestroyImmediate(child.gameObject); } } }
public void LoadInsideEditor() { GOMap map = GetComponent <GOMap> (); if (map == null) { Debug.LogError("[GOMap Editor] GOMap script not found"); return; } map.BuildInsideEditor(); }
public static void AddMap() { GameObject locationManager = CreateGameObjectInScene("Location Manager"); CenterOnScreen(locationManager, 0); GameObject newMap = CreateGameObjectInScene("Map"); CenterOnScreen(newMap, 0); GOMap map = newMap.AddComponent <GOMap> (); map.locationManager = locationManager.AddComponent <LocationManager>(); GOLayer buildings = new GOLayer(); buildings.layerType = GOLayer.GOLayerType.Buildings; buildings.isPolygon = true; buildings.defaultRendering = new GORenderingOptions(); buildings.defaultRendering.polygonHeight = 2; buildings.defaultRendering.material = CreateMaterialWithColor(Color.white); GOLayer water = new GOLayer(); buildings.layerType = GOLayer.GOLayerType.Water; water.isPolygon = true; water.defaultRendering = new GORenderingOptions(); water.defaultRendering.polygonHeight = 0; water.defaultRendering.material = CreateMaterialWithColor(Color.blue); GOLayer landuse = new GOLayer(); buildings.layerType = GOLayer.GOLayerType.Landuse; landuse.isPolygon = true; landuse.defaultRendering = new GORenderingOptions(); landuse.defaultRendering.polygonHeight = 0; landuse.defaultRendering.material = CreateMaterialWithColor(Color.green); GOLayer roads = new GOLayer(); buildings.layerType = GOLayer.GOLayerType.Landuse; roads.isPolygon = false; roads.defaultRendering = new GORenderingOptions(); roads.defaultRendering.lineWidth = 2; roads.defaultRendering.material = CreateMaterialWithColor(Color.gray); map.layers = new GOLayer[] { buildings, water, landuse, roads }; Camera.main.transform.position = new Vector3(0, 600, 100); Camera.main.transform.eulerAngles = new Vector3(70, 180, 0); }
public IEnumerator LoadTileData(GOMap m, Coordinates tilecenter, int zoom, GOLayer[] layers, bool delayedLoad) { map = m; tileCoordinates = tileCenter.tileCoordinates(map.zoomLevel); if (Application.isPlaying) { yield return(StartCoroutine(DownloadData(m, tileCenter, zoom, layers, delayedLoad))); List <string> layerNames = map.layerNames(); yield return(StartCoroutine(ParseTileData(map, tileCenter, zoom, layers, delayedLoad, layerNames))); } else { GORoutine.start(DownloadData(m, tileCenter, zoom, layers, delayedLoad), this); } }
public void BuildLine(GameObject line, GOLayer layer, GORenderingOptions renderingOptions, GOMap map) { if (feature.convertedGeometry.Count == 2 && feature.convertedGeometry[0].Equals(feature.convertedGeometry[1])) { return; } if (renderingOptions.tag.Length > 0) { line.tag = renderingOptions.tag; } if (renderingOptions.material) { renderingOptions.material.renderQueue = -(int)feature.sort; } if (renderingOptions.outlineMaterial) { renderingOptions.outlineMaterial.renderQueue = -(int)feature.sort; } GOLineMesh lineMesh = new GOLineMesh(feature.convertedGeometry); lineMesh.width = renderingOptions.lineWidth * Global.tilesizeRank; lineMesh.load(line); mesh = lineMesh.mesh; mesh = SimpleExtruder.Extrude(mesh, line, 0.05f); line.GetComponent <MeshFilter>().sharedMesh = mesh; line.GetComponent <Renderer>().material = renderingOptions.material; Vector3 position = line.transform.position; position.y = feature.y * Global.tilesizeRank; line.transform.position = position; if (renderingOptions.outlineMaterial != null) { GameObject outline = CreateRoadOutline(line, renderingOptions.outlineMaterial, Global.tilesizeRank * (renderingOptions.lineWidth + layer.defaultRendering.outlineWidth)); if (layer.useColliders) { outline.AddComponent <MeshCollider>().sharedMesh = outline.GetComponent <MeshFilter>().sharedMesh; } outline.layer = line.layer; outline.tag = line.tag; } else if (layer.useColliders) { // Mesh m = gameObject.GetComponent<MeshFilter> ().sharedMesh; line.AddComponent <MeshCollider>(); } }