Ejemplo n.º 1
0
        public override IEnumerator ParseTileData(object m, Coordinates tilecenter, int zoom, GOLayer[] layers, bool delayedLoad, List <string> layerNames)
        {
            if (mapData == null)
            {
                Debug.LogWarning("Map Data is null! ASYNC tileurl: " + this.tileUrl);
                                #if !UNITY_WEBPLAYER
                FileHandler.Remove(gameObject.name);
                                #endif
                yield break;
            }
            float t0 = Time.time;

            GOPbfProcedure procedure = new GOPbfProcedure();
            procedure.tileData   = (byte[])mapData;
            procedure.zoomlevel  = map.zoomLevel;
            procedure.tileCoords = tileCoordinates;
            procedure.layers     = layers;
            procedure.tile       = this;
            procedure.Start();

            if (Application.isPlaying)               //Runtime build

            {
                yield return(StartCoroutine(procedure.WaitFor()));

                float t1 = Time.time;

                foreach (GOParsedLayer p in procedure.list)
                {
                    yield return(StartCoroutine(BuildLayer(p, delayedLoad)));
                }

//				Debug.Log ("time parsing: " + (t1 - t0) + "  Total time: " + (Time.time - t0));
            }
            else               //In editor build

            {
                while (!procedure.Update())
                {
                }
            }

            Complete = true;

            yield return(null);
        }
Ejemplo n.º 2
0
        public override IEnumerator ParseTileData(GOLayer[] layers, bool delayedLoad, List <string> layerNames)
        {
            byte[] mapData = goTile.getVectorData();

            if (mapData == null)
            {
                Debug.LogWarning("Map Data is null! ASYNC");
                FileHandler.Remove(gameObject.name);
                yield break;
            }
            DateTime t0  = DateTime.Now;
            float    t0s = Time.time;

            GOPbfProcedure procedure = new GOPbfProcedure();

            procedure.goTile       = goTile;
            procedure.layers       = layers;
            procedure.tile         = this;
            procedure.onMainThread = map.runOnMainThread;
            procedure.Start();

            if (Application.isPlaying)               //Runtime build

            {
                yield return(StartCoroutine(procedure.WaitFor()));

                float t1s = Time.time;
                goTile.status = GOTileObj.GOTileStatus.Loaded;

                if (goTile.useElevation)
                {
                    MeshFilter filter = GetComponent <MeshFilter> ();
                    filter.sharedMesh = procedure.goTile.goMesh.ToMesh(recalculateNormals_: false);

//					MeshCollider collider = GetComponent<MeshCollider> ();
//					collider.sharedMesh = filter.sharedMesh;
                }

                foreach (GOParsedLayer p in procedure.list)
                {
                    yield return(StartCoroutine(BuildLayer(p, delayedLoad)));
                }


                goTile.status = GOTileObj.GOTileStatus.Done;
                //Resources.UnloadUnusedAssets();

//				Debug.Log (string.Format("Procedure Time: {0}, Total time: {1}", (t1s-t0s), (Time.time - t0s)));
//				Debug.Log (string.Format("Terrain time: {0}, Features Time: {1}, POI Time: {2}, Total time: {3}",procedure.tT.Subtract(t0).Milliseconds, procedure.tF.Subtract(procedure.tT).Milliseconds, procedure.tP.Subtract(procedure.tF).Milliseconds, DateTime.Now.Subtract(t0).Milliseconds));
            }
            else               //In editor build

            {
                while (!procedure.Update())
                {
                }
            }

            if (Application.isPlaying)
            {
                Destroy(goTile.featurePrototype);
                Destroy(goTile.streetnamePrototype);
            }

            if (map.OnTileLoad != null)
            {
                map.OnTileLoad.Invoke(this);
            }

            base.OnTileLoaded();

            yield return(null);
        }