Пример #1
0
        public virtual IEnumerator CreateLine(GOTile tile, bool delayedLoad)
        {
            GORenderingOptions renderingOptions = GetRenderingOptions();

            if (renderingOptions.lineWidth == 0)
            {
                yield break;
            }

            GOFeatureMeshBuilder builder = new GOFeatureMeshBuilder(this);

            featureCenter = builder.center;
            GameObject line = null;

            if (preloadedMeshData != null)
            {
                line = builder.BuildLineFromPreloaded(this, tile.map, parent);
            }

            if (line == null)
            {
                yield break;
            }

            line.name = name != null? name:kind.ToString();

            //Layer mask
            if (layer.useLayerMask == true)
            {
                tile.AddObjectToLayerMask(layer, line);
            }

            if (goTile.addGoFeatureComponents)
            {
                GOFeatureBehaviour fb = line.AddComponent <GOFeatureBehaviour> ();
                fb.goFeature = this;
            }

            //Mapzen Streetnames
            if (goTile.mapType == GOMap.GOMapType.Mapzen_Legacy && layer.layerType == GOLayer.GOLayerType.Roads && name != null && name.Length > 0 && goTile.useStreetnames && !isLoop && !goTile.useElevation)
            {
                GOStreetName streetName = GameObject.Instantiate(goTile.streetnamePrototype, line.transform).GetComponent <GOStreetName>();
                streetName.gameObject.name = name + "_streetname";
                yield return(tile.StartCoroutine(streetName.Build(name, this)));
            }

            if (layer.OnFeatureLoad != null)
            {
                layer.OnFeatureLoad.Invoke(this, line);
            }

            if (delayedLoad)
            {
                yield return(null);
            }
        }
        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);

            if (preloadedMeshData != null)
            {
                builder.BuildLineFromPreloaded(line, this, tile.map);
            }
            else if (tile.map.mapType == GOMap.GOMapType.MapzenJson)
            {
                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 = "";
                streetName.transform.SetParent(line.transform);
                yield return(tile.StartCoroutine(streetName.Build(name, tile.map.textShader, tile.map.streetnameColor)));
            }

            if (layer.OnFeatureLoad != null)
            {
                layer.OnFeatureLoad.Invoke(builder.mesh, layer, kind, builder.center);
            }

            if (delayedLoad)
            {
                yield return(null);
            }
        }
Пример #3
0
        public virtual IEnumerator CreateLine(GOTile tile, bool delayedLoad)
        {
            //if ()
            //GORenderingOptions renderingOptions = GetRenderingOptions();
            float          lineWidth;
            int            unityLayer;
            GOFeatureEvent goFeatureEvent;

            if (layer != null)
            {
                lineWidth      = renderingOptions.lineWidth;
                unityLayer     = layer.unityLayer;
                goFeatureEvent = layer.OnFeatureLoad;
            }
            else
            {
                lineWidth      = tileSetLineRendering.witdh;
                unityLayer     = tilesetLayer.unityLayer;
                goFeatureEvent = tilesetLayer.OnFeatureLoad;
            }


            if (lineWidth == 0)
            {
                yield break;
            }

            GOFeatureMeshBuilder builder = new GOFeatureMeshBuilder(this);

            featureCenter = builder.center;
            GameObject line = null;

            if (preloadedMeshData != null)
            {
                line = builder.BuildLineFromPreloaded(this, tile.map, parent);
            }

            if (line == null)
            {
                yield break;
            }

            line.name = name != null ? name : kind.ToString();

            //Layer mask
            line.layer = unityLayer;

            if (goTile.addGoFeatureComponents)
            {
                GOFeatureBehaviour fb = line.AddComponent <GOFeatureBehaviour>();
                fb.goFeature = this;
            }

            //Mapzen Streetnames
            if ((goTile.mapType == GOMap.GOMapType.Nextzen || goTile.mapType == GOMap.GOMapType.Mapbox) && layer != null && layer.layerType == GOLayer.GOLayerType.Roads && name != null && name.Length > 0 && goTile.useStreetnames && !isLoop && !goTile.useElevation)
            {
                GOStreetName streetName = GameObject.Instantiate(goTile.streetnamePrototype, line.transform).GetComponent <GOStreetName>();
                streetName.gameObject.name = name + "_streetname";
                yield return(tile.StartCoroutine(streetName.Build(name, this)));
            }

            if (goFeatureEvent != null)
            {
                goFeatureEvent.Invoke(this, line);
            }

            if (delayedLoad)
            {
                yield return(null);
            }
        }