public virtual IEnumerator CreateLine(GOTile tile, bool delayedLoad) { GORenderingOptions renderingOptions = GetRenderingOptions(); if (renderingOptions.lineWidth == 0) { yield break; } GameObject line = new GameObject(name != null ? name : kind.ToString()); line.transform.parent = parent.transform; //Layer mask if (layer.useLayerMask == true) { tile.AddObjectToLayerMask(layer, line); } GOFeatureMeshBuilder builder = new GOFeatureMeshBuilder(this); builder.BuildLine(line, layer, renderingOptions, tile.map); GOFeatureBehaviour fb = line.AddComponent <GOFeatureBehaviour>(); fb.goFeature = this; if (layer.layerType == GOLayer.GOLayerType.Roads && name != null && name.Length > 0 && renderingOptions.useStreetNames) { GOStreetName streetName = new GameObject().AddComponent <GOStreetName>(); streetName.gameObject.name = name + "_streetname"; streetName.transform.SetParent(line.transform); yield return(tile.StartCoroutine(streetName.Build(name))); } if (layer.OnFeatureLoad != null) { layer.OnFeatureLoad.Invoke(builder.mesh, layer, kind, builder.center); } if (delayedLoad) { yield return(null); } }
public virtual IEnumerator CreatePolygon(GOTile tile, bool delayedLoad) { GameObject polygon = null; GORenderingOptions renderingOptions = GetRenderingOptions(); GOFeatureMeshBuilder builder = new GOFeatureMeshBuilder(this); //Materials Material material = tile.GetMaterial(renderingOptions, builder.center); Material roofMat = renderingOptions.roofMaterial == null ? renderingOptions.material : renderingOptions.roofMaterial; if (sort != 0) { if (material) { material.renderQueue = -(int)sort; } if (roofMat) { roofMat.renderQueue = -(int)sort; } } //Group buildings by center coordinates if (layer.layerType == GOLayer.GOLayerType.Buildings && defaultRendering) { GameObject centerContainer = tile.findNearestCenter(builder.center, parent, material); parent = centerContainer; material = centerContainer.GetComponent <GOMatHolder>().material; } int offset = 0; if (!layer.useRealHeight) { height = renderingOptions.polygonHeight; } if (height == 0f) { height = 0.05f; } polygon = builder.BuildPolygon(name, layer, height + offset); polygon.GetComponent <Renderer>().material = material; //} if (polygon == null) { yield break; } if (name == "") { name = "某大楼"; } polygon.name = name; polygon.transform.parent = parent.transform; //Layer mask if (layer.useLayerMask == true) { tile.AddObjectToLayerMask(layer, polygon); } if (renderingOptions.tag.Length > 0) { polygon.tag = renderingOptions.tag; } Vector3 pos = polygon.transform.localPosition; if (layer.useRealHeight && roofMat != null) { roof = builder.CreateRoof(); roof.name = "roof"; roof.transform.parent = polygon.transform; roof.GetComponent <MeshRenderer>().material = roofMat; roof.transform.position = new Vector3(roof.transform.position.x, height + 0.01f, roof.transform.position.z); roof.tag = polygon.tag; roof.layer = polygon.layer; if (y < 1f) { y = 0.02f; } } if (height > 1f) { polygon.AddComponent <BuildingCollider>().InitRoot(roof); } /* if (y > 0.45f) * { * y = 0.01f; * } * else*/ if (y == 0.2f || y == 0.096f || this.kind == GOFeatureKind.commercial || this.kind == GOFeatureKind.recreation_ground || this.kind == GOFeatureKind.attraction) { y = 0.02f; } else if (y == 0.098f) { y = 0.03f; } // y = y * Global.tilesizeRank; pos.y = y; //polygon.transform.position = pos; polygon.transform.localPosition = pos; GOFeatureBehaviour fb = polygon.AddComponent <GOFeatureBehaviour>(); fb.goFeature = this; if (layer.OnFeatureLoad != null) { layer.OnFeatureLoad.Invoke(builder.mesh, layer, kind, builder.center); } if (delayedLoad) { yield return(null); } }